Codeigniter

CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.

If your not currently using an MVC framework, you could do a lot worse than check out Codeigniter, its simple to install and use, and its free. Whats not to like ?

Setting up codeigniter for a new project is one of those things that you occassionally need to do, and inevitably you can never quite remember precisely what you need to do to to get things up and running. Here’s our step by step process

1 – Download the latest version from https://codeigniter.com/

2 – Create a new folder for your project under your web servers htdocs directory (e.g. myApp)

3 – Copy the codeigniter folders into your project folder, myApp/applications, myApp/system etc.

4 – Open up your web browser and navigate to localhost/myApp. You should see the default code igniter welcome page.

5 htaccess file: Removing the index.php file

By default, the index.php file will be included in your URLs:

example.com/index.php/news/article/my_article

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the “negative” method in which everything is redirected except the specified items:

General Configuration

For small projects everything kind of works out of the box, but you’ll probably want to make a few configuration changes to make life easier, add a database etc.

Changes to application/config.php

you’ll probably want to make URL’s in your app relative to your top level domain. Generally you’ll use codeigniters functions base_url() or site_url(). These values get set right here.

$config[‘base_url’] = ‘http://localhost/myApp/’;

Adding a Database

If the application requires a database, you’ll need to supply credentials in the following configuration file:  application/config/database.php

Leave a comment