
CodeIgniter
I’ve seen quite a few CodeIgniter tutorials and screencasts out there and none that I have seen seem to cover everything that I thought should be covered in an initial install. I decided I would finally try to put together one of my own to help some of the newer members get things going, as well as try to give a decent enough explanation to the MVC architecture so that you will understand what’s going on. So, enough talking, here we go.
Preparation
We will start off by getting you ready to start with CodeIgniter. For this instructional, I will explain things as if you are completely starting from scratch. This will include downloading and installing the CodeIgniter framework as well as installing a local web server.
If you already have a web server up and running, you can skip this part and move on to downloading and installing CodeIgniter.
Download and Install XAMPP

XAMPP Control Panel - Click Start
For this tutorial I will use the XAMPP to setup a local development environment. For those you who don’t know, XAMPP is an Apache based web server that comes pre-configured with installations of MySQL, PHP, and Perl. At the time of writing this post, the most current distribution of XAMPP is 1.7.1. XAMPP can be downloaded here. (Note: This tutorial will not work for the latest version of XAMPP. XAMPP 1.7.2 has been released and comes bundled with PHP 5.3 which has known issues with CodeIgniter 1.7.1. I will get an updated tutorial on the differences and how to get things rolling with XAMPP 1.7.2 ASAP).
After you have downloaded XAMPP, run the executable to extract the files to your location of choice. I chose to extract to the root of the C: drive so that XAMPP will be located at C:\xampplite. Navigate to this directory and run the setup_xampp.bat file.
The next step will be starting up Apache and ensuring that everything is working up to this point. To do this, run xampp-control.exe. This is the XAMPP Control Panel. Here you will be able to start and stop all the needed services or access phpmyadmin. Go ahead and click on the Start button to the right of the Apache label. Now jump over to your browser of choice and enter http://localhost into the address bar and press enter.
You should now see the default XAMPP installation page. If you do then we are ready to move on to CodeIgniter.
Download CodeIgniter
Now it’s time to move on the CodeIgniter installation. At the time of writing this tutorial CodeIgniter is also in version 1.7.1. Check the CodeIgniter site to find the latest version.
CodeIgniter and MVC Background

MVC Data Flow
CodeIgniter is a powerful, lightweight PHP based framework that is based off of the MVC (Model – View – Controller) architecture. A lot of people have a hard time grasping MVC but it is really not that complicated. MVC is designed to separate you code from presentation, allowing you to create views that are very clean and minimal on PHP. Let’s talk about MVC a little more in depth for a second.
Models – Models are typically used to perform any database interaction. By using a model to do all data retrieval, you leave other layers like the controller for gathering/prepping all the data for display. Models are not restricted to only database interaction though. You can push any functionality that you wish out to a model.
Views – Views contain all presentation layer code (HTML, CSS, etc). View files should be something that you are comfortable with.
Controller – The controller is what ties everything together. When to go to a url hosted on a CodeIgniter site, the controller is in charge of gathering all data needed for the page and then passing that data to the view files for display in your browser.
On top of the MVC architecture, CodeIgniter also has a large selection of code libraries available at your disposal. These libraries provide simplified access to functions such as:
- Validating user form input
- Querying databases
- Managing user sessions
- Manipulating images
- and more… See CI User Guide for a complete list
CodeIgniter also has a long list of helpers available. Helpers provide a host of common functions to simply normal tasks such as opening forms, sending emails, and more. Once again, the complete list of helpers is available in the CodeIgniter User Guide.
Installing CodeIgniter. Finally!
Now that we’ve got you a little more familiar with what CodeIgniter is and how some of the pieces work together, its time to move on to the installation. CodeIgniter’s installation is extremely simple. Hopefully you already have CodeIgniter downloaded. If you do, navigate to the htdocs directory within your XAMPP installation directory, and remove all of the current files there. Next extract the CodeIgniter, and move all files in the inner CodeIgniter_1.7.1 subfolder into the htdocs folder and navigate back to http://localhost in your browser once again. At this point, you should now be greeted with the default CodeIgniter welcome page.
That’s all there is to it. You now have CodeIgniter up and running locally. I plan to continue these tutorials and will help you figure out where to go and what to do now that you have things running. We’ll cover creating your first controller, view, and issues with index.php.









Twitter Updates

not working for me. I have done as you told above.
Could you provide any kind of explanation of what didn’t work? These instructions were written as I walked through this process myself. If you give me a better explanation of what happened, perhaps I can help you out.
If you downloaded a newer version of XAMPP than was used in this tutorial, then the CodeIgniter install may still work, but will generate errors. This is caused by the newest version of PHP being provided within the latest XAMPP installation. XAMPP 1.7.2 includes PHP 5.3 by default, which has known issues with CodeIgniter 1.7.1. If you check the CodeIgniter SVN, you can find newer versions of CodeIgniter that supposedly fix these issues. Otherwise, you will need to use a previous version of XAMPP that does not include PHP 5.3. XAMPP version 1.7.1 was used for this tutorial.
Thank you very much for taking so much of pain to write this article….
It is very easy to understand & implement. This is what i was looking for… Thank you again
Works Great.. Excellent article for beginners. Thanks a lot.. Keep up the good work…
I have a client using this exact setup. When I install as described, Xampp works fine. If I put CI in the folder, I as well just keep getting the Xampp page by default when going to 127.0.0.1 address. In addition, the client has already made files they have given me that I thought should be able to be dragged and dropped but this does not seem to work either. I feel like I probably have to change a setting but I am not s familiar with this so I am not sure what to do. Any advice would be greatly appreciated. TY