Autoloading in CI 2.0 |
[eluser]Dan Horrigan[/eluser]
If you are like me, you would like class autoloading supported in CI 2.0. I have a fork of CI 2.0 and have added this functionality. I have added this functionality, and it works great. It adds nearly zero over head. It only autoloads libraries, models and helpers...if you use static methods for helpers :-). It uses the CI_Loader functions, so all module paths are respected.. Here is how to use it: Example for loading a library: Code: $auth = new Auth(); Code: Auth::logged_in(); You can also use it for Models: Code: $user = new User_model(); You models can still use $this->db. I particularly like it for helpers (i know EllisLab says they should be procedural, but I like static methods...Issue #29): Code: Form::open('email/send'); If you like the idea encourage them to add it in. Issue #33 Here are my changesets (forgot to remove debug code the first time around :-P): https://bitbucket.org/dhorrigan/codeigni...aec4b35443 https://bitbucket.org/dhorrigan/codeigni...e9ac090a14 Dan |
Welcome Guest, Not a member yet? Register Sign In |