How I start a new CodeIgniter Project

Every other day, I develop new websites from scratch for various clients and sometimes for some of my own projects. Unless the project is really complex, I prefer to develop in CodeIgniter, a super-flexible (MVC) PHP framework which lets me develop super-quick !

It is thus wise to have a standard pattern to follow each time I start a new project. This is what I do –

1. First, the usuals –

2. Making point to MyProjectFolder –

  • Edit the /private/etc/hosts file, add these lines –

# XYZ Project

  •  Edit the .htaccess file in Apache DocumentRoot, add these lines –

# for
RewriteCond %{HTTP_HOST} ^(www\.)?MyProject\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/MyProjectFolder
RewriteRule ^(.*)$ /MyProjectFolder/$1 [L]

2. Navigate into MyProject and,

  • Delete user-guide (un-necessary clutter since it is available online anyway)
  • Add (short project description)

3.  Create a folder named static/ within MyProject. This will include all the stylesheets, images, fonts, javascripts etc.

4. Create a .htaccess file within MyProjectFolder/

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt|static)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

This will enable serving static content and also enable clean URLs.

( instead of

5. Create 3 folders within application/config/ –

  • development
  • testing
  • production

Make sure that ‘ENVIRONMENT’ is set to ‘development’ in MyProjectFolder/index.php

Copy database.php and config.php inside these folders and delete the original one. Then, inside the development folder, setup the development environment –

  •  Create a mysql database for the project and make changes in config/development/databases.php accordingly
  • Create a folder db_scripts inside config folder and keep a record of all sql queries (create table scripts) executed on the database inside this folder.
  • Set base_url, encryption key, index_page etc. in config/development/config.php and

6. Edit config/routes.php file, set default controller to home (or whatever you wish)

7. Setup logging – Use third party library ci_log4php (This integrates Log4PHP with CodeIgniter)

  • Refer my blogpost here for instructions on how to set it up

9. Setup Email (Optional) – Use the default Email helper for internal error-mails, notifications etc. and setup Sendgrid for emails sent to users. (I ll probably cover this in detail in another post)

  • UPDATE : Here is the post.

10. Setup Auth – Use a third party library tank_auth [Download]

  • Just follow the above link to download tank_auth and simply replace or add all the files and folders it contains.
  • The config file is well documented and its easy to customize with a lot of options to set up a logging system exactly as you need

11. Push code to git

  • Create a new repo on git and get the url git://
  • Create the .gitignore file and select the codeigniter template
  • Locally, at the root directory of your source, git init
  • git remote add origin <URL From Step 1>
  • git pull origin master
  • git add .
  • git commit -m “First commit”
  • git push origin master

Typically the entire process should take around 30-40 minutes :)



  1. Once you’ve done the steps once, you could save time by cloning the base repo for each new project.

  2. One thing though, it’s “CodeIgniter”, no hyphen. The community is actually picky about that, believe it or not. :)

  3. @Casey – True, that would save steps 5 to 10. However, you wont get the latest version of CodeIgniter that way. Gives a good feeling when one downloads the latest one each time :D
    @Jack : Point noted, Thank you :)

  4. @Mayank Going on @Casey’s comment, you can link the CodeIgniter repo using the git submodule feature so your base project That way you can either have the latest, or a specific branch.

  5. @Rushi : Thanks, this looks interesting, will give it a shot !

  6. Only the system folder changes, so you could just pull that from the git repo each time

    1. whoops! missed Rushi’s comment

  7. Reblogged this on Sam's PHP How-To and commented:
    This is a bit over my head but could come in handy!

  8. […] promised in my previous post, here are the steps to set up email on CI using SendGrid […]

  9. Muhammad Zubair · · Reply

    although CI is a good MVC framework of php
    but there is a framework more powerful than CI called Yii (Yes it is); the more reliable and secure

  10. I think that is among the so much important information
    for me. And i’m satisfied studying your article. However want to remark on some basic issues, The website taste is ideal, the articles is actually nice : D. Just right job, cheers

  11. It’s an remarkable article in favor of all the online people; they will get benefit from it I am sure.

  12. We are a gaggle of volunteers and starting a new scheme in our community.

    Your website provided us with useful information to work on.
    You’ve done an impressive task and our entire neighborhood might be thankful to you.

  13. Howdy are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and create my
    own. Do you need any html coding expertise to make your own blog?
    Any help would be greatly appreciated!

  14. You’ve got great information on this site.

  15. Again, movie-intensive work or gambling involves more than normal amounts of Memory probably 2-4GB (gigabytes).
    At the end of time, you have to consider a phone and
    choose what’s best for you.

  16. Fantastic beat ! I would like to apprentice while you amend your website, how can i subscribe for a
    blog web site? The account helped me a acceptable deal.
    I had been a little bit acquainted of this your broadcast provided bright clear

  17. Hi there colleagues, how is all, and what you want to say regarding this paragraph, in my view its genuinely
    awesome in support of me.

  18. This mosaic Happy Halloween flag or banner is so easy and
    affordable to make. I love mosaics, but they are heavy, time consuming,
    and sometimes just not in the budget!

    Homemade Cleaner #3 – The next cleaning agent that we recommend is quaternary ammonium.
    Don’t use bleach banner maker as it is not recommended. Follow the
    instructions mentioned below for cleaning with vinegar.

    You can easily find quaternary ammonium at a home improvement store.

    So on a Friday evening after work I made biscuits.
    I wasn’t exactly looking forward to it and
    wondered if messing in flour and shortening
    was the way I really wanted to spend my time.
    I had the evening to myself so my goal was to get in there,
    make’em quick and move on to something better.

    Carefully place a layer of ice in the large coffee can around the outside of
    the smaller coffee can. Sprinkle a little salt over the ice cubes.
    Place another layer of ice on top of the salt and then sprinkle some
    more salt on that ice. Continue making these layers of
    ice and salt until the can is filled to the top.

    This device has a range of settings so that you can vary the color of your waffles from
    very light to very dark, and everything in between. It heats up
    very quickly so it is ready to go within a couple of minutes.
    However, some of this will depend on your mixture as you will need some sugar to ensure that caramelization takes place.

    You can do targeting by both criteria even if you advertise on
    a single site. Limit you banner placement to certain categories and you can also ask to show your banner only to visitors
    from certain location. Good ad serving software
    can check IP and show different ads.

    The American television producer and actor did some important fashion choices in the
    period of 80’s. In this Cosby Sweater Project, each episode offers different kinds of game to recreate
    his magic loud shirts.

  19. That way you will have the greatest effects, at all timeframe.
    And you are assured by me, with MaxiPatch your erotic lifestyle is
    going to be a lot better than ever. How about anything penis
    formed that is bite size?

  20. Few notes if developing on mac :

    Document root is /Library/WebServer/Documents
    chmod -R 777 /Library/WebServer/Documents

    sudo nano /etc/apache2/httpd.conf
    load various modules including php mod_rewrite etc.

    AllowOverride All in httpd.conf

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

%d bloggers like this: