CodeIgniter autoload specific classes
Go to applications/config/autoload.php
and in there you can edit what you need.
They are in arrays and seperated by packages
, libraries
, helpers
, config
, languages
and models
.
eg
$autoload['libraries'] = array('database', 'session');$autoload['helper'] = array('url', 'html', 'form');
I only wanted to auto load Public_Controller
in the frontend and Admin_Controller
in admin, so autoload.php
is out. In autoload.php
the files are loaded globally. The __autoload()
function only tries to auto load a class when it's called, but not found.
there is no need to write autoload functioncodeigniter has its own file for auo loading files like libraries and helper
You can add class name there in the specific array
The file name should be "autoload.php" in application/config/ directory