-
Notifications
You must be signed in to change notification settings - Fork 26
Php5 magic Autoloader
[h2]Plugin Introduction[/h2]
[b]Advantages:[/b]
- [color=red]Get Everything Everywhere[/color]: No more get_instance() for use CI inside model, library, helper, or view
- [color=red]Lazy-load support[/color]: No more $this->load->something(). Resources automatically loads (only first time, only if needed)
- [color=red]100% Back\Forward CI Compatibility[/color]: All the logic work delegated to standard CI Core
- [color=red]More concise syntax[/color]: Faster code typing style, better read style that make more sense. Bye bye $this->
- [color=red]Non-obtrusive[/color]: If you wish, you can switch syntax modes, or even use them both. No refactor needed for "pre-plugin" code
- [color=red]No core hacking is required[/color]: Simply download and load it just like any other plugin.
[b]Requirements:[/b]
- CodeIgniter 1.5+
- PHP5+
[b]Version 1.2 Changelog: (downloads: 23)[/b]
- Added Support Codeigniter <= 1.7.3
- Added Plugins()
- Added Configs()
- Added Vars()
- Added Helpers()
- Lightweight coding style.
- All logic work delegated to CI Core for compatibility propose
- Added support for ALL original functions params ($this->load->xxx('name', 'args1', 'args2'))
- Renamed "Libs" in "Libraries" (a little longer, but reading style come first!).
[b]Version 1.3 Changelog: (downloads: 7)[/b]
- Added more controls for downsize overhead
- Added Php5 Helpers Mode :)
- Added Plugin suffix
[b]Version 1.4 Changelog: (downloads 8)[/b]
- Added Langs()
- Added Modularity for Configs, Helpers, Langs (es. Configs('rss')->line('ip');)
- Libraries re-renamed in "Libs" by popular acclaim (lol)
- Added more and more and more controls for downsize overhead
- Better Docs
[b]Version 1.5 Changelog: (downloads: 8)[/b]
- Added Libs('uri')->something(); support for CI parent instance
- Check Control for Core CI Libs Autoloaded (Uri, Input, Config etc...). Now faster
- Created CI Wiki page
[b]Version 1.6 Changelog:[/b]
- Check Control for Modularity Class (Configs, Langs, Helpers). Now faster
- Fix Libraries and Models Alias CI Support
- Added (facoltative) Extended Syntax
- Better Docs
[b]Installation:[/b] This is a plugin so no core hacking is required. Simply [url="http://codeigniter.com/forums/viewthread/134786/"]download[/url], extract it into your [b]application/plugins[/b] folder. (auto)Load it just like any other plugin.
[b]Credits[/b] Based on Modularity Plugin by Jonathon Hill (http://codeigniter.com/forums/viewthread/99960/P15/)
[h2]How to use the Plugin[/h2]
[h3]Views[/h3]
[code]
$this->load->view('news_view', $data);
Views('news', $data); [/code]
[h3]Libraries[/h3]
[code]
$this->load->library('mylibrary'); $this->mylibrary->do_something();
Libs('mylibrary')->do_something(); // the library automatically loads if needed
Libs('input')->post('name'); Libs('output')->set_header('HTTP/1.0 200 OK'); Libs('session')->userdata('id'); [/code]
[h3]Models[/h3]
[code]
$this->load->model('news_model'); $this->news_model->do_something();
Models('news')->do_something();// the model automatically loads if needed [/code]
[h3]Langs[/h3]
[code]
$this->load->language('filename'); $this->lang->line('language_key');
Langs('filename')->line('language_key');// the language automatically loads if needed
Langs('filename'); Langs()->line('language_key'); [/code]
[h3]Plugins[/h3]
[code]
$this->load->plugin('captcha'); $this->captcha->do_something();
Plugins('captcha')->do_something();// the plugin automatically loads if needed [/code]
[h3]Configs[/h3]
[code]
$this->config->load('filename'); $this->config->item('itemname');
Configs('filename')->item('itemname'); // the config automatically loads if needed [/code]
[h3]Helpers[/h3]
[code]
$this->load->helper('date'); echo now();
echo Helpers('date')->now(); // the helper automatically loads if needed
Helpers('date'); echo now(); [/code]
[h3]Vars[/h3]
[code]
$this->load->vars(array('page_type' => 'section'));
Vars(array('page_type' => 'section')); [/code]
[h3]Databases[/h3]
[code]
$this->load->database(); $query = $this->db->query($sql);
$query = DBS()->query($sql);// the "default" database automatically loads if needed [/code]
[h3]Multiple database connections[/h3]
[code]
$dbh1 = $this->load->database('db1', TRUE); $dbh2 = $this->load->database('db2', TRUE); $query1 = $dbh1->query($sql); $query2 = $dbh2->query($sql);
$dbh1 = DBS('db1')->query($sql);// the "db1" database automatically loads if needed $dbh2 = DBS('db2')->query($sql);// the "db2" database automatically loads if needed [/code]
[h3]Inside libraries, helpers, models, views etc...[/h3]
[code]
$CI =& get_instance(); $CI->load->model('news_model'); $CI->news_model->do_something();
Models('news')->do_something();// The same for all resources [/code]
[h3][color=red]Facoltative[/color] extended syntax[/h3]
[code]
Views::load('news', $data);
Libs::load('mylibrary')->do_something();
Models::load('news')->do_something();
Langs::load('filename');
Plugins::load('captcha')->do_something();
Helpers::load('date');
Vars::load(array('page_type' => 'section'));
DBS::load(); [/code]