First Hands-On CodeIgniter 2.0

Development version of CodeIgniter 2.0 is now available in BitBucket (no stable or RC yet!). Last week, I tested all my apps and found out what are changes to be done for your app to work in CI 2.0

New CodeIgiter’s new code

Hooray! At last, CodeIgniter supports PHP5 and all Object Oriented stuff supported like __get(), __set() (read more).
Download the code from BitBucket or if you have hg repository,
hg clone http://bitbucket.org/ellislab/codeigniter

Ok So what are the changes!
  • All deprecated are gone! If you know meaning of deprecated, then I hope you have already stopped using those.
    • Validation class no more!
    • DB methods removed. These were deprecated since 1.6 (orwhere, orlike, groupby, orhaving, orderby and getwhere)
  • Application folder is now outside the system, by default. If you are not following the system of placing CI core files outside your app in a common location, then you have to do so
  • CI class names like Controller, Model, etc now have a new name CI_Controller, CI_Model, etc
  • New config files profiler.php & foreign_chars.php
  • Constructors are strictly __construct() for core classes. So, parent::__construct() and no parent::Controller() in your constructors
  • No plugins, only helpers. Now, this solved by question why we need a plugin when there is a helper!
  • Extenders in your controllers (your controller extending MY_Controller) are no more libraries. You have to place it in a new folder called ‘core’ in your apps.
  • Behaviour of Query String in urls changed
  • Language class CI_Language is now CI_Lang
Making your app do its in CI 2.0
  • Change CI class names with prefix CI_
    From
    class projb_model extends ModelTo
    class projb_model extends CI_Model
  • If you are not following strict PHP5 and using constructors in your controllers & models, then change parent::Controller() or parent::Model() to parent::__construct()
    function __construct(){
    parent::__construct();
    //your stuff
    }
  • Move your plugins to helpers folder and rename with suffix _helper
  • Replace index.php in your app with new code and update any changes
  • Extended Libs or MY_Controller goes to system/core folder.
  • If you are using old deprecated validation lib and really (really!) want to use that, then only way to make it work is to copy from your old ci system and place it in your app libraries folder. But, try to be smart enough to use the new smart form_validation lib.
  • Check $config[‘enable_query_string’] in config.php Because, if enabled in ci 2.0, it will generate urls like /index.php?/controller, or /?/controller.
  • Finally check your code for deprecated DB methods (orwhere, orlike, groupby, orhaving, orderby and getwhere)

I hope that wraps up. If anything I find more, I ll update. 🙂

5 Replies to “First Hands-On CodeIgniter 2.0”

  1. i ll stick to 1.7.3. thanks, thought will be useful aft release. until stable, no peek into it for me

Leave a Reply

Your email address will not be published. Required fields are marked *