Slide 1

Slide 1 text

CodeIgniter 101 By: Chris Schmitz

Slide 2

Slide 2 text

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?

Slide 3

Slide 3 text

Why should I use it? ● Lightweight CodeIgniter: ~ 4MB CakePHP: ~ 7MB Zend: > 15MB Symfony: ~ 13MB

Slide 4

Slide 4 text

Why should I use it? ● Lightweight ● Fast

Slide 5

Slide 5 text

Why should I use it? ● Lightweight ● Fast ● Backwards compatible

Slide 6

Slide 6 text

Why should I use it? ● Lightweight ● Fast ● Backwards compatible ● Infinitely extensible (Sparks)

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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)

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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!

Slide 15

Slide 15 text

What can it do? ● Helpers to make your life easier: ○ Arrays ○ CAPTCHA ○ Cookie ○ Dates ○ Downloads ○ Email ○ Files ○ HTML ○ Language ○ Smilies ○ URL ○ and more!

Slide 16

Slide 16 text

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.

Slide 17

Slide 17 text

A Sample Request

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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.

Slide 20

Slide 20 text

See it in action Live coding!

Slide 21

Slide 21 text

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.

Slide 22

Slide 22 text

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!

Slide 23

Slide 23 text

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