Share
Embed
CodeIgniter 101
An intro to CodeIgniter presentation I gave at the Fox Cities PHP meetup.
Chris Schmitz
May 29, 2012
Transcript
23 slides
-
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? -
Why should I use it? • Lightweight CodeIgniter: ~ 4MB
CakePHP: ~ 7MB Zend: > 15MB Symfony: ~ 13MB -
Why should I use it? • Lightweight • Fast •
Backwards compatible -
Why should I use it? • Lightweight • Fast •
Backwards compatible • Infinitely extensible (Sparks) -
Why should I use it? • Lightweight • Fast •
Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers -
Why should I use it? • Lightweight • Fast •
Backwards compatible • Infinitely extensible (Sparks) • Comes with a lot of libraries and helpers • SEO/User-friendly URLs -
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 -
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) -
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 -
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 -
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 -
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! -
What can it do? • Helpers to make your life
easier: ◦ Arrays ◦ CAPTCHA ◦ Cookie ◦ Dates ◦ Downloads ◦ Email ◦ Files ◦ HTML ◦ Language ◦ Smilies ◦ URL ◦ and more! -
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. -
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 -
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. -
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. -
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! -
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