3.3. Initial Configuration

In this section, you learn the ins and outs of the files inside the system/application/config/ folder. This folder contains an assortment of files (including the index.html file). Of those files, four of them are important enough to warrant attention now. Those files, in order of importance for your project, are:

  • config.php

  • database.php

  • 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.

3.3.1. 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 ...

Get Professional CodeIgniter® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.