Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CodeIgniter 101

CodeIgniter 101

An intro to CodeIgniter presentation I gave at the Fox Cities PHP meetup.

Chris Schmitz

May 29, 2012
Tweet

More Decks by Chris Schmitz

Other Decks in Programming

Transcript

  1. An open source PHP application framework Provides a lot of

    pre built functionality and conventions for code organization that let you focus on building out the logic for your applications. What is CodeIgniter?
  2. Why should I use it? • Lightweight CodeIgniter: ~ 4MB

    CakePHP: ~ 7MB Zend: > 15MB Symfony: ~ 13MB
  3. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks)
  4. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers
  5. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs
  6. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs • Flexible URI Routing
  7. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs • Flexible URI Routing • A Command Line Interface (CLI)
  8. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs • Flexible URI Routing • A Command Line Interface (CLI) • Great documentation
  9. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs • Flexible URI Routing • A Command Line Interface (CLI) • Great documentation • A very active/helpful community
  10. Why should I use it? • Lightweight • Fast •

    Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs • Flexible URI Routing • A Command Line Interface (CLI) • Great documentation • A very active/helpful community • It is being actively developed
  11. What can it do? • Libraries for almost anything you

    need to build web apps: ◦ Database abstraction ◦ Session management ◦ Encryption ◦ File uploads ◦ Form validation ◦ Shopping cart ◦ Caching ◦ Security ◦ Benchmarking ◦ and more!
  12. What can it do? • Helpers to make your life

    easier: ◦ Arrays ◦ CAPTCHA ◦ Cookie ◦ Dates ◦ Downloads ◦ Email ◦ Files ◦ HTML ◦ Language ◦ Smilies ◦ URL ◦ and more!
  13. MVC • Model: Represents your data structures. Handles interaction with

    the database. • View: The information being presented to the user. • Controller: An intermediary between the Model and the View, and any other resources needed to process the HTTP request. This provides a separation of concerns and gives you a logical place to put all of your code for different parts of your application.
  14. CodeIgniter associates URI strings with controller classes and methods. http://example.com/users/show/1

    Gets routed to the show method of the users controller and passes a parameter with a value of 1 to the method. class Users extends CI_Controller { public function show($id) { // grab the user from the database or something... } } Routing
  15. Extensibility Sparks is a package management system just for CodeIgniter.

    Composer and Packagist are starting to pick up traction as a standardized way to share libraries across all PHP applications. In addition to integrating third-party code, you can also extend CI's core classes with ease.
  16. The Future • Test coverage • Not a lot of

    new feature development • Many long-time CI developers are changing frameworks The Bottom Line: It's a very dependable, backwards compatible, and easy to learn framework and is well-suited for lightweight web applications. However, if you want to play with the latest and greatest, there are other options you will probably be happier with.
  17. Self-Promotion Perm: A simple, flexible access control system Decorator: Allows

    you to create decorators (aka presenters) to prep data before returning it to the view These repos are pull request-friendly!
  18. Thanks! I'm Chris Schmitz. Hit me up on Twitter (@ccschmitz)

    with any CodeIgniter questions! Demo app can be fount on GitHub at: https: //github.com/foxcitiesphp/ci-demo-app