Why CodeIgniter? The CI MVC Model. CI Basics. Running CI out of the box ...
CodeIgniter MVC. Implementation ... CI application flow. Stolen from CI user
guide ...
Introduction to CodeIgniter Ed Finkler • http://funkatron.com • @funkatron codeworks09
Thee Agenda Why CodeIgniter? The CI MVC Model CI Basics Running CI out of the box Making a basic web app Making a web api
http://www.flickr.com/photos/alternatewords/2332580309/
Why CodeIgniter?
Why not CakePHP or Zend Framework or Limonade or Symfony or Solar or Kohana or Zoop or Yii or Akelos or PHP on Trax or Prado or Seagull?
Because you've gotta pick one, dammit
All of them have value
That being said, CI is… Easy to understand Simple doesn't require advanced OOP Doesn't force lots of conventions Plays well with others Quick to get up and running Good docs and great community Backed by invested entity (http://ellislab.com)
CodeIgniter MVC Implementation
More like "Passive View Pattern" Controller
View
http://short.ie/5o7eg4
Model
CI application flow
Stolen from CI user guide
App components Front controller
Helper
Routing
Plugin
Security
Scripts
Controller
View
Model
Caching
Library
Front controller
index.php
Routing http://domain.com/index.php/controller/method/param
class Search extends Controller { public function single($id) { // [...] } }
Security
Filtering or blocking unsafe input
Controller The core of everything
Model ActiveRecord pattern available, not required Query binding $sql = "SELECT * FROM some_table WHERE id = ? AND status = ? AND author = ?"; $this->db->query($sql, array(3, 'live', 'Rick'));
Don't like the DB layer? Use something else Zend_DB, Doctrine, DataMapper (http://bit.ly/ datamapper), IgniteRecord (http://bit.ly/igrec) …
Library
A class designed to work on related tasks
Helper Procedural funcs, grouped by file Mostly for views; available in controllers /** * Plural * * Takes a singular word and makes it plural * * @access public * @param string * @param bool * @return str */ function plural($str, $force = FALSE) { // [...] }
Plugin Single procedural function More extensive functionality than helper $vals = array( 'word' 'img_path' 'img_url' 'font_path' 'img_width' 'img_height' 'expiration' );
=> => => => => => =>
$cap = create_captcha($vals); echo $cap['image'];
'Random word', './captcha/', 'http://example.com/captcha/', './system/fonts/texb.ttf', '150', 30, 7200
Script
Other scripts the CI app might use
View Build response to client CI Views are limited Uses plain PHP as templating lang