CodeIgniter Basic Configuration Using Auto load
In continuation of our CodeIgniter tutorials, the next step we are setting up some basic configuration. We can manage our CodeIgniter configuration from application/config directory. The config directory contains the group of files which handle your application configuration.
Using Auto load:
The file atutoload.php comes under application/config directory. And used for Auto Loading Resources globally throughout your application. In order to keep the framework as light-weight as possible, only the absolute minimal resources are loaded by default. You should load only those things that use over and over in your application. The “Auto-load” feature in CodeIgniter permits following things of your application to autoload:
- Packages
- Libraries
- Drivers
- Helper files
- Custom config files
- Language files
- Models
Packages −
Using package we can load third party package from third party directory under application directory or a specific directory passing through an array().
$autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
Libraries −
It is a list of libraries that you can autoload passing through array list. For example following essential libraries like database, email, session, form_validation you can auto load.
$autoload['libraries'] = array('database', 'form_validation', 'session','grocery_CRUD','parser');
Drivers −
These classes are located in the system/libraries folder or in your application/libraries folder within their own subdirectory. They offer multiple interchangeable driver options.
$autoload['drivers'] = array('cache');
Helper files −
It is a list of helper files, to be autoloaded. Provide a list of libraries in the array, as shown below, to be autoloaded by CodeIgniter. In the given example, we are autoloading URL and file helpers.
$autoload['helper'] = array('form','url', 'security');
Config files −
It is used for custom config files. Otherwise, leave it blank. CodeIgniter automatically loads the primary config file (application/config/config.php), so you will only need to load a config file if you have created your own for the deferent environment. We will describe haw to configure multiple environments later on.
$autoload['config'] = array();
Language files −
If you find that you need a particular language globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the language(s) to the autoload array.
$autoload['language'] = array('lang1', 'lang2');
Models −
Using models you can load frequently used model, For example, you have a user_model for frequent use than load model on auto-load.
$autoload['model'] = array('user_model');
Subroto Mondal
Latest posts by Subroto Mondal (see all)
- Installing and Configuring OpenShift: A Step-by-Step Guide for Linux Experts with Terminal Code - February 19, 2023
- Sed Command in Linux with Practical Examples - February 19, 2023
- Rsync Command uses with examples - February 19, 2023
2 Pingbacks
CodeIgniter Database Configuration - NHIT Tech Blog
CodeIgniter library - NHIT Tech Blog