Setting up Code Igniter

February 13, 2010 | 2 Comments

A few months ago, we jumped into Teeorama, a PHP based online tee-shirt store front end for Spreadshirt. We finally completed the project and we’re planning on opening it to the public tomorrow. By the way, if you feel you could use a new Geek shirt, please head over to before reading on…

When I started the development, I decided to use both a PHP and a Javascript framework I didn’t know. I had two reasons for doing that:

  • It’s always interesting to play with new code. You get to see how other people/framework solved common problems, how some libraries make this or that easier  to use for the developer. You also sometimes realize some other things are carried out better in the framework you are used to. Either way, it is a good learning experience.
  • Also, I wanted to stay away from the stack we use at work to not be tempted and not be able to just copy over bits of our blueKiwi framework into my code

So, I picked CodeIgniter and jQuery to build my website. In the end, I am very pleased with the experience of working with these two tools. CodeIgniter is exactly what it claims to be: a very light but powerful framework that does not try to command the way you work. Of course, jQuery is just as powerful as its reputation. It’s incredibly easy to get used to and I haven’t found anything it couldn’t do.

Anyway, this post is about setting up Code Igniter. There is a Code Igniter user_guide (included in the downloaded zip file) to do just that and it would take you about two seconds to get going. The thing is, I did not like the way Code Igniter was laid out in my folder. I wanted to be able to place the framework in a library folder within my application folder and make my web folder (containing the images, javascript and css files) the document root therefore keeping my application folder out of exposure to the Web.

This is also possible though it does involve some minor tweaking of CodeIgniter base code.

First, here is my chosen folder layout

Second, as I said, I made the web folder the target of my Apache virtual host.
Here is my virtual host for this application

ServerAdmin your_email
ServerName project_domain
AddDefaultCharset UTF-8
DocumentRoot /var/www/project/web

RewriteEngine On
RewriteCond $1 !^/?(index\.php|test|images|web|js|css)
RewriteRule ^(.*)$ /index.php/$1 [L]

Finally, in order for all this to work, you need to tweak a couple of CodeIgniter files

define the system and application folders paths as follow in index.php:

$docRootPath = dirname($_SERVER['DOCUMENT_ROOT']);
$system_folder = $docRootPath."/application/libraries/codeigniter";
$application_folder = $docRootPath."/application";

Also, modify the CodeIgniter.php file at the bottom of index.php to:

require_once BASEPATH.'CodeIgniter'.EXT;

Finally, edit CodeIgniter.php in order to replace all occurrences of “codeigniter/” by “” (nothing)

You should be setup. Happy coding!

Filed under: Computing, PHP

Tagged with: , , , , ,

Liked this page?

Tweet it

Subscribe to the RSS feed or sign up for the newsletter now.

Posts related to Setting up Code Igniter

2 Comments to "Setting up Code Igniter"

  1. Trackback on samantha on February 14, 2010 at 1:30 pm

    New blog post: Setting up Code Igniter: A few months ago, we jumped into Teeorama, a PHP based online tee-shirt st…

  2. Trackback on Samantha Halfon on February 14, 2010 at 1:30 pm

    New blog post: Setting up Code Igniter: A few months ago, we jumped into Teeorama, a PHP based online tee-shirt st…

Name (required)

Email (required)


Leave a Reply

  • About Me

    photo of Samantha Halfon Samantha Halfon
    Software Engineer
    blueKiwi software
    Paris, France
    I enjoy playing with my computer(s), listening to Bob Dylan (and related artists) and watching movies (especially if they were directed by Martin Scorsese or John Cassavetes). Sometimes, I play a little guitar... If not doing any of the above, I am either riding a small red bike around Paris, or, making videos. About my videomaking please check out World Wide Angle and its blog.