To autoload resources, open the application/config/autoload.php file and add the item you want loaded to the autoload array.
Important Points Of Autoload Concept
- This file specifies which systems should be loaded by default (OR) The files initialized automatically every time the system runs.
- Frequently used systems should be autoload instead of called at the local level repeatedly.
- Used to keep the framework as light-weight
- If your application needs global resource, make it autoload
- For example, the database is not connected to automatically since no assumption is made regarding whether you intend to use it. This file lets you globally define which systems you would like loaded with every request.
1. Libraries 2. Helper files 3. Custom config files 4. Language files 5. Models
LibrariesThese are the classes located in the 'application/libraries' folder or in your application/libraries folder. $autoload option 'libraries' is a list of libraries that should be loaded. eg.database, session, e-mail, form validations etc.
$autoload['libraries'] = array();
HelperThese are the classes located in the 'application/helper' folder. $autoload option 'helper' is a list of helper collections that you will need to get work done. eg. URL, form, text helpers etc.
$autoload['helper'] = array();
ConfigThese are the classes located in the 'config' folder. This item is intended for use ONLY if you have created custom config files. Otherwise, leave it blank.
$autoload['config'] = array();
LanguageThese are the classes located in the 'system/language' folder.
$autoload['language'] = array();
ModelThese are the classes located in the 'models' folder. $autoload option 'model' allows you to autoload models.
$autoload['model'] = array();
Sample autoload.php configuration
$autoload['libraries'] = array('database','session','email','validation'); $autoload['helper'] = array('url','form','text','date','security'); $autoload['model'] = array(); $autoload['config'] = array();