CodeIgniter is one of the most popular PHP frameworks around. It uses the Model-View-Controller Architectural design pattern and it’s considered by lots of PHP developers as one of the best framework solution for small to medium projects. In this article we will cover how to install CodeIgniter and we will view the most common configuration abilities of the famous MVC framework.
How to Install
The installation itself is such a simple process. First of all, you need to download the CodeIgniter zipped file, upload it to your server and extract it into your home directory. You can download it from https://ellislab.com/codeigniter/user-guide/installation/downloads.html.
Congratulations, now you have CodeIgniter installed on your server. Now it’s time for configuration. Open the application/config/config.php file with your preferred editor and set your base URL. If you intend to use encryption or sessions, set your encryption key. For the database configuration, open the application/config/database.php file with your preferred editor and set your database host, name, user, password and other values that you think it will help you connect to your database. You will find array variables with comments to know the role of each value.
The Configuration files
By editing the two previously mentioned files, you are ready to start coding your first web application but CodeIgniter contains more files that enable more configuration and customization abilities. The configuration files can be found in the application/config/ directory. The following is a quick description of what you can do by editing some of the most commonly used configuration files:
– autoload.php: specifies which systems (Packages, Libraries, Helper files, Custom config files, Language files and Models) should be loaded by default.
– config.php: contains all website configuration.
– constants.php: contains defined constants which are used when checking and setting modes when working with the file system.
– database.php: contains the settings needed to access your database.
– email.php: This file is not created by default. But you can create it and set the default values for the email class. Like: mailtype, charset, newline, protocol, smtp_host, etc.
– hooks.php: lets you define “hooks” to extend CI without editing the core files.
– mime.php: contains an array of mime types. It is used by the upload class to help identify allowed file type.
– routes.php: lets you re-map URI requests to specific controller functions.
– smileys.php: contains an array of smileys for use with the emoticon helper.
– upload.php: This file is not created by default. But you can create it and set the default values for the upload class. Like: upload_path, allowed_types, max_size, max_width, max_height, etc.
– user_agents.php: contains four arrays of user agent data. It is used by the User Agent Class to help identify browser, platform, robot, and mobile device data. The array keys are used to identify the device and the array values are used to set the actual name of the item.
Now, we have viewed the most common CodeIgniter configuration files. Next, we will work on writing your first web application using CodeIgniter framework.
Books to read