Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Benefits of the CodeIgniter Framework


Published on

Toby Beresford's slides from the PHP London Conference 08 on CodeIgniter - part of a comparison with Zend and Symfony

Published in: Technology

Benefits of the CodeIgniter Framework

  1. 1. CodeIgniter PHP Framework Toby Beresford [email_address]
  2. 2. Content <ul><li>Bio </li></ul><ul><li>Benefits </li></ul><ul><li>Why Frameworks </li></ul><ul><li>MVC </li></ul><ul><li>Demo </li></ul><ul><li>Links </li></ul>
  3. 3. Toby Bio <ul><li>12 years – professional Web App Development </li></ul><ul><ul><li>5 years - Lotus Domino </li></ul></ul><ul><ul><li>7 years – PHP </li></ul></ul><ul><ul><li>8 months - CodeIgniter </li></ul></ul><ul><li>Toby Beresford Applications Ltd </li></ul><ul><li>Platform applications </li></ul><ul><ul><li>Facebook </li></ul></ul><ul><ul><li>Bebo, Myspace et al. </li></ul></ul><ul><li>Clients </li></ul><ul><ul><li>Sky News,, Comic Relief, VideoJug, AfffiliateWindow, .name registry…. </li></ul></ul><ul><li>[email_address] / </li></ul><ul><li>h </li></ul>
  4. 4. Benefits of CI <ul><li>Small </li></ul><ul><li>Fast </li></ul><ul><li>Simple </li></ul><ul><li>Customer ready </li></ul><ul><ul><li>a sys admin can install the CI framework in a few minutes </li></ul></ul><ul><ul><li>great documentation means easy hand over: new developers just learn the framework not your home grown MVC code </li></ul></ul><ul><li>Great for mash-up apps using multiple platforms </li></ul><ul><ul><li>eg. Facebook apps </li></ul></ul><ul><li>Cleaner code </li></ul>
  5. 5. Why Frameworks No framework Framework Me and my framework Framework Platform API Me, my framework and a Platform API
  6. 6. MVC <ul><li>View (views/frog_count.php) </li></ul><ul><ul><li><html> </li></ul></ul><ul><ul><li><body> </li></ul></ul><ul><ul><ul><li><h1> You’ve <?=$froggies;?> items in list</h1> </li></ul></ul></ul><ul><ul><ul><li></body> </li></ul></ul></ul><ul><ul><li></html> </li></ul></ul><ul><li>Controller (controllers/my_controller.php) </li></ul><ul><ul><li>function total_frogs () { </li></ul></ul><ul><ul><ul><li>$this->load->model(“frogs”); </li></ul></ul></ul><ul><ul><ul><li>$number_of_frogs = $this->frogs->count_frogs(); </li></ul></ul></ul><ul><ul><ul><li>$data[‘froggies’] = $number_of_frogs; </li></ul></ul></ul><ul><ul><ul><li>$this->load->view(“frog_view”, $data); </li></ul></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>Model (models/frogs.php) </li></ul><ul><ul><li>function count_frogs() { </li></ul></ul><ul><ul><ul><li>$this->db->where(“type”,”frog”); </li></ul></ul></ul><ul><ul><ul><li>$this->db->from(“animals”); </li></ul></ul></ul><ul><ul><ul><li>$query = $this->db->get(); </li></ul></ul></ul><ul><ul><ul><li>Return $query->num_rows(); </li></ul></ul></ul><ul><ul><ul><li>} </li></ul></ul></ul>Model View Controller
  7. 7. How to run a CI method <ul><li>http:// </li></ul>Where you’ve installed CI Your main controller file: System/application/controllers/my_controller.php The name of a method in your controller
  8. 8. Download from
  9. 9. Upload to your server
  10. 10. See the welcome screen
  11. 11. Create your database
  12. 12. Configure CodeIgniter Base URL
  13. 13. Configure Database Connection
  14. 14. Create a controller
  15. 15. Add the view
  16. 16. Try it
  17. 17. Send variables to the view via an array VIEW CONTROLLER
  18. 18. And…
  19. 19. Model: Get item <ul><li>Uses ActiveRecord </li></ul>
  20. 20. Model: Put Item
  21. 21. Model: Get all
  22. 22. Model: Delete Item
  23. 23. Controller: Add
  24. 24. View: Add/Edit
  25. 25. User Interface: Add
  26. 26. Controller: Save
  27. 27. Controller: Edit
  28. 28. User Interface: Edit
  29. 29. Controller: List all
  30. 30. Views: List <ul><li>Note we can use ordinary PHP in the views, no template language to learn </li></ul>
  31. 31. User Interface: List
  32. 32. Controller: Delete
  33. 33. Views: Delete Confirm
  34. 34. User Interface: Delete
  35. 35. Class Libraries and Helpers Helper Reference Array Helper Cookie Helper Date Helper Directory Helper Download Helper Email Helper File Helper Form Helper HTML Helper Inflector Helper Path Helper Security Helper Smiley Helper String Helper Text Helper Typography Helper URL Helper XML Helper Class Reference Benchmarking Class Calendaring Class Config Class Database Class Email Class Encryption Class File Uploading Class FTP Class HTML Table Class Image Manipulation Class Input and Security Class Loader Class Language Class Output Class Pagination Class Session Class Trackback Class Template Parser Class Unit Testing Class URI Class User Agent Class Validation Class XML-RPC Class Zip Encoding Class
  36. 36. Summary <ul><li>CI is fast to run, light to deploy and easy to learn </li></ul><ul><li>Great for mash-up applications in the platform world </li></ul><ul><ul><li>Wishlist = Eg. AffiliateWindow retailer list API, product API, Facebook UI, Facebook User tables, + PayPal mass pay for commissions </li></ul></ul>
  37. 37. Useful links <ul><li> </li></ul><ul><ul><li>User manual, community forums, releases </li></ul></ul><ul><li> </li></ul><ul><ul><li>PHP5 CodeIgniter fork </li></ul></ul><ul><li> </li></ul><ul><ul><li>All the frameworks side by side </li></ul></ul><ul><li> </li></ul><ul><ul><li>Contractor site with a skills category for the major PHP Frameworks </li></ul></ul><ul><li> </li></ul><ul><ul><li>Facebook Developer Garage – 5 th March </li></ul></ul><ul><li>Questions? </li></ul><ul><ul><li>[email_address] </li></ul></ul>