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.

Ci2

2,456 views

Published on

My CodeIgniter 2.0.0 slides from #cicon2010!

Published in: Education
  • great slides!!

    I wasn't at the conf. and would have loved to know how much of the 2.0.0 features have been implemented and what is left.

    Thanx.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Ci2

  1. 1. CodeIgniter 2.0.0 Adam Griffiths @adam_griffiths adamgriffiths.co.uk adam@adamgriffiths.co.uk bitbucket.org/adamgriffiths/
  2. 2. Who am I? • Author of programmersvoice.com • AG Auth - Easiest Auth Library for CI • AG Asset - simple Asset Management Library • Author of CodeIgniter 1.7 Professional Development
  3. 3. CodeIgniter 2.0.0 • What’s been removed • What’s been deprecated • What’s changed • What’s new • Tips for upgrading
  4. 4. What’s been removed
  5. 5. Goodbye Scaffolding • Deprecated for a number of versions • Wasn’t a very good implementation • Has now been removed for CodeIgniter 2.0.0
  6. 6. Au revoir Plugins • Removed in favour of Helpers • Nobody was ever sure what they were for • Plugins & Helpers were too similar • You should update your Plugins to Helpers
  7. 7. Validation Class • Deprecated since 1.7.0 • More powerful FormValidation Class should be used instead
  8. 8. Deprecations
  9. 9. PHP 4 • Support now dropped for PHP 4 • YAY!! • New CI 2 features may not support PHP 4 • All legacy features will no longer support PHP 4 as of 2.1.0
  10. 10. Changes...
  11. 11. Application Directory • How many of you move your application directory out of the system directory? • That won’t be an issue in CI2
  12. 12. index.php • Configuration values can now be stored here. • Allows a single application to have multiple front controllers with different configuration values. • Routing overrides now added. • Limits your application to one controller.
  13. 13. What’s new?
  14. 14. Drivers • New type of library • Parent class and any number of child classes • CI Database Library could be a Driver
  15. 15. Using Drivers • $this->load->driver(‘driver_name’); • $this->driver_name->method(); • $this->driver_name->subclass->subclass_method();
  16. 16. Creating a Driver
  17. 17. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  18. 18. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  19. 19. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  20. 20. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  21. 21. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  22. 22. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  23. 23. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  24. 24. File Structure application/ libraries/ driver_name/ Driver_name.php drivers/ Driver_name_subclass_1.php Driver_name_subclass_2.php
  25. 25. Parser File Structure application/ libraries/ Parser/ Parser.php drivers/ Parser_dwoo.php Parser_smarty.php
  26. 26. Parser File Structure application/ libraries/ Parser/ Parser.php drivers/ Parser_dwoo.php Parser_smarty.php
  27. 27. Parser File Structure application/ libraries/ Parser/ Parser.php drivers/ Parser_dwoo.php Parser_smarty.php
  28. 28. Parser File Structure application/ libraries/ Parser/ Parser.php drivers/ Parser_dwoo.php Parser_smarty.php
  29. 29. Parser File Structure application/ libraries/ Parser/ Parser.php drivers/ Parser_dwoo.php Parser_smarty.php
  30. 30. Parser File Structure application/ libraries/ Parser/ Parser.php drivers/ Parser_dwoo.php Parser_smarty.php
  31. 31. Parser.php Class <?php class Parser extends CI_Driver_Library { } // class ?>
  32. 32. Parser.php Class <?php class Parser extends CI_Driver_Library { } // class ?>
  33. 33. Parser.php Class <?php class Parser extends CI_Driver_Library { } // class ?>
  34. 34. <?php class Parser extends CI_Driver_Library { function __construct() { $this->valid_drivers = array('parser_dwoo', ‘parser_smarty’); } // _construct() } // class ?>
  35. 35. function __construct() { $this->valid_drivers = array('parser_dwoo', ‘parser_smarty’); } // _construct()
  36. 36. Parser_dwoo.php Class <?php class Parser_dwoo extends CI_Driver { } // class ?>
  37. 37. Parser_dwoo.php Class <?php class Parser_dwoo extends CI_Driver { } // class ?>
  38. 38. Parser_dwoo.php Class <?php class Parser_dwoo extends CI_Driver { } // class ?>
  39. 39. Packages • Allows for easy distribution of resources in a single directory. • Can have it’s own library files, models, config files etc. • Placed in application/third_party • MojoMotor addons are packages
  40. 40. Creating a Package
  41. 41. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  42. 42. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  43. 43. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  44. 44. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  45. 45. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  46. 46. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  47. 47. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  48. 48. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  49. 49. Package File Structure application/ third_party/ package_name/ config/ helpers/ language/ libraries/ models/
  50. 50. Add Package Path • Before you can load a package, you need to tell the Loader where to look for it. • $this->load- >add_package_path(APPPATH.'third_party/package_name/'); • $this->load->library(‘package_name’);
  51. 51. Remove Package Path • When finished using a Packages resources. • When you want to use multiple Packages. • $this->load- >remove_package_path(APPPATH.'third_party/package_nam e/');
  52. 52. PackageView Files • Disclaimer: not finished • Save the original view path • Set the view path to that of the Package • Load views, etc • Set the path back to the original
  53. 53. // ... save the original view path, and set to our package view folder $orig_view_path = $this->load->_ci_view_path;$this->load->_ci_view_path = APPPATH.'third_party/package_name/views/';// ... code using the package's view files// ... then return the view path to the application's original view path$this->load->_ci_view_path = $orig_view_path; $orig_view_path = $this->load->_ci_view_path;$this->load->_ci_view_path = APPPATH.'third_party/package_name/views/';// ... code using the package's view files// ... then return the view path to the application's original view path$this->load->_ci_view_path = $orig_view_path; $orig_view_path = $this->load->_ci_view_path;$this->load->_ci_view_path = APPPATH.'third_party/package_name/views/';// ... code using the package's view files// ... then return the view path to the application's original view path$this->load->_ci_view_path = $orig_view_path;
  54. 54. Mercurial/BitBucket • In development code is now hosted on BitBucket • Easier to get *your* code in the CI core • Allows community to help squish bugs • No SVN!! (Sorry but I really do hate Subversion)
  55. 55. Quick and Dirty Mercurial Tutorial
  56. 56. The Basics • hg init • hg pull <url> • hg pull <constant> • hg pull <path/to/local/repo> • hg update
  57. 57. Continued... • hg diff • hg add . • hg add <path/to/file> • hg commit -m “Commit Message” • hg push <url> • hg push <constant>
  58. 58. .hgrc file • mate $HOME/.hgrc • [paths] • ci_master = http://bitbucket.org/ellislab/codeigniter/
  59. 59. Upgrading Tips
  60. 60. Upgrading your Models • CodeIgniter 1.7.2 Models extend Model • CodeIgniter 2.0.0 Models extend CI_Model
  61. 61. Lazy mans Model Upgrade • Create a new Library file: MY_Model.php <?php class Model extends CI_Model { function __construct() { parent::__construct(); } // construct() } // class ?>
  62. 62. Lazy mans Model Upgrade • Create a new Library file: MY_Model.php <?php class Model extends CI_Model { function __construct() { parent::__construct(); } // construct() } // class ?>
  63. 63. Lazy mans Model Upgrade • Create a new Library file: MY_Model.php <?php class Model extends CI_Model { function __construct() { parent::__construct(); } // construct() } // class ?>
  64. 64. Lazy mans Model Upgrade • Create a new Library file: MY_Model.php <?php class Model extends CI_Model { function __construct() { parent::__construct(); } // construct() } // class ?>
  65. 65. Controllers • Controllers are currently unchanged • Ellis Lab are evaluating changing the Controller class from Controller to CI_Controller
  66. 66. Lazy mans Controller Upgrade • Create a new Library file: MY_Controller.php <?php class Controller extends CI_Controller { function __construct() { parent::__construct(); } // construct() } // class ?>
  67. 67. Lazy mans Controller Upgrade • Create a new Library file: MY_Controller.php <?php class Controller extends CI_Controller { function __construct() { parent::__construct(); } // construct() } // class ?>
  68. 68. Lazy mans Controller Upgrade • Create a new Library file: MY_Controller.php <?php class Controller extends CI_Controller { function __construct() { parent::__construct(); } // construct() } // class ?>
  69. 69. Lazy mans Controller Upgrade • Create a new Library file: MY_Controller.php <?php class Controller extends CI_Controller { function __construct() { parent::__construct(); } // construct() } // class ?>
  70. 70. Summary • Plugins,Validation Library & Scaffolding have been removed • PHP 4 support dropped • Drivers & Packages • Model Class renamed • Mercurial/Bitbucket
  71. 71. Q & A • @adam_griffiths • Skype: adam-griffiths • adam@adamgriffiths.co.uk • www.adamgriffiths.co.uk • www.bitbucket.org/adamgriffiths/

×