CodeIgniter Beginner Tutorial 1–Configuring CodeIgniter

In this tutorial I’m going to show you how to configure codeIgniter.




Here are some of the links that you might want to check out in the process of learning how to do things in CodeIgniter.

  • Nettuts – Everything you need to know to get started with CodeIgniter – this is a pretty good tutorial. Though its already getting old, most of the concepts, methods and configurations that you need to do is still the same with the current version of CodeIgniter(v2.1.0)
  • CodeIgniter User Guide – A very good reference for the different methods and helper classes available in CodeIgniter. This is a very valuable resource once you know basics of CodeIgniter.
  • Nettuts CodeIgniter From Scratch – A series of screencast which discusses how to work with CodeIgniter. I recommend it if you’re not low on bandwidth.
  • Stackoverflow – If you get stuck in your quest on learning CodeIgniter you can just search for your problem on Stackoverflow. There’s a big probability that you’re problem has already been answered before.


Base URL

First you have to download CodeIgniter then unzip it on your web folder. If you’re using Wampserver its on c:\wamp\www if you haven’t configured anything when you installed Wampserver. If you’re using XAMPP your web folder is somewhere in c:\xampp\htdocs. But don’t take my word for it, I’m not a XAMPP user so you might as well do your research.

After unzipping you’ll have a folder structure similar to this.


Next open up the application folder and then the config folder.

application > config

Inside the config folder you will see the config.php file, open it up and set the base url. The base url is the root location that you will be working on. It looks similar to this.

$config['base_url']	= 'http://localhost:8080/tester/codeigniter/index.php/';


Database Configuration

Still on the same folder open up the database.php file. This is where you will set what database codeIgniter is going to use. Here are the stuff that you’re going to edit.

$db['default']['hostname'] = 'localhost';

$db['default']['username'] = 'root';

$db['default']['password'] = '';

$db['default']['database'] = 'database_name';

$db['default']['dbdriver'] = 'mysql'; //optional, you can use mysqli if you want

If you don’t know what you’re going to set just use localhost for the hostname, root for the username and an empty password. The database is up to you to fill out, just create a database for testing purposes if you’re just starting out with codeIgniter. You can create it in phpmyadmin or the mysql console.



Next you need to specify the libraries, packages, helper files, custom configuration files, language files and models that you want to autoload in your application. This means that anything that you autoload in your application doesn’t need to be called every time you need to use it. To edit the libraries, helper files, and models that you want to autoload in your application just open up the autoload.php file which is in the application/config folder.
Below is an example where I included the database library in the libraries that will be autoloaded in the application. To do that just add database as an item to the libraries array.

$autoload['libraries'] = array('database');

There are other libraries available in codeIgniter which you can find on codeigniter/system/libraries folder. You can also add them to the libraries array but be sure you know how to use them and make sure not to load more than what you need.


You might also want to autoload some of the helpers that you might use later on. The url helper and the form helper. Helpers are used to make your life easier, if you translate it into coding this means that you get to write less code and do more.

$autoload['helper'] = array('url', 'form');


Default Controller

This is actually an optional configuration so you can just skip it if you want. But if you want to setup a default controller then read along.
The default controller is the controller that’s going to be loaded when you access the root of your application. In this case the root of the application points to the address below.


To setup the default controller open up the routes.php file, still under the application/config folder and find the line similar to the following.

$route['default_controller'] = "site";

The default controller on the example above is the site controller, the site controller must be on the application/controllers folder otherwise this will fail. If you have a different name for your default controller, for example your default controller is index.php then change the default controller to index.


I guess that’s all you need to configure for now. Be sure to check out the resources that I’ve mentioned earlier.

7 thoughts on “CodeIgniter Beginner Tutorial 1–Configuring CodeIgniter

  1. The Autoload step after Database Configuration requires editing the file autoload.php. Default routes are edited in the file routes.php

    Both are located in the same folder as the previous 2 edits.


    This is a terrible tutorial.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s