Chapter 3: A 10,000 - Foot View of CodeIgniter
50
autoload.php
routes.php
The following sections go into more detail on each file. Please don ’ t skip the information in these
sections, as they contain instructions, hints, and tips that will make your CodeIgniter work much faster
and easier. These instructions and tips are built upon trial and error and will keep the confusion and
restarts down to a minimum.
config.php
The config.php file contains a series of configuration options (all of them stored in a PHP array called,
appropriately enough, $config ) that CodeIgniter uses to keep track of your application ’ s information
and settings.
The first configuration option you need to set inside config.php is the base URL of your application. You
do that by setting the absolute URL (including the http:// part) for $config[ ‘ base_url ’ ] , like so:
$config[‘base_url’] = “http://www.example.com/test/”;
Once you ’ ve set this configuration option, you can recall it whenever you want using the CodeIgniter
base_url() function, which can be a very handy thing to know. This one feature keeps you from
having to rewrite hard - coded URLs in your application, when you migrate from development to test or
from test to production.
The second thing you need to do is set a value for your home page by editing the $config[ ‘ index_
page ’ ] configuration option. CodeIgniter ships with a value of “ index.php ” for this option, which
means that index.php will appear in all of your URLs. Many CodeIgniter developers prefer to keep this
value blank, like so:
$config[‘index_page’] = ‘’;
To make this work, you need to include an .htaccess file to the CodeIgniter root directory, as was
discussed previously, in the section “ CodeIgniter at a Glance ” in this chapter.
After you ’ ve set this option value, there ’ s very little to do. For now, leave all the other values at their
default settings:
$config[‘uri_protocol’] = “AUTO”;
$config[‘url_suffix’] = “”;
$config[‘language’] = “english”;
$config[‘charset’] = “UTF-8”;
$config[‘enable_hooks’] = FALSE;
$config[‘subclass_prefix’] = ‘MY_’;
$config[‘permitted_uri_chars’] = ‘a-z 0-9~%.:_-’;
$config[‘enable_query_strings’] = FALSE;
$config[‘controller_trigger’] = ‘c’;
$config[‘function_trigger’] = ‘m’;
$config[‘log_threshold’] = 0;
$config[‘log_path’] = ‘’;
$config[‘log_date_format’] = ‘Y-m-d H:i:s’;