Setting up Codeigniter
I have been working with (and enjoying) Codeigniter a lot lately it’s a great small, lightweight PHP Web framework. It’s really good if you are looking for a simple to learn framework that uses the MVC pattern. The steps below are the things I do to set it up on my local machine to get started on a new project.
- Download the latest version of Codeigniter.
- Extract the contents of the download file to the desired location where the web site you will be building will be stored (in my example, I am putting this folder in my public_html folder)
- Go inside the folder where Codeigniter was extracted to.
- The “user_guide” folder contains the documentation for Codeigniter. If you are new to Codeigniter I would recommend that you keep this folder. If you are familiar with Codeigniter you can remove this (the user_guide is available online for your reference).
- Go into the “system/application/config” folder and edit the $config[‘base_url’] to point to a local web site (example on my machine: http://localhost/~ed/ci). Save your changes.
- Open up your web browser and browse to the location where you have set up the Codeigniter files. If all is well, you should see a welcome message stating that you have set up Codeigniter!
Removing index.php from URL
When you first start using Codeigniter you will see that the URLs of the system have ‘index.php’ in them. If you want to remove this file you will need to use the mod_rewrite apache module and create a .htaccess file. Follow the steps below to accomplish this:
Enable mod_rewrite (this will be different for each Linux distribution, please follow the applicable steps to enable this). In Ubuntu 10.10 use the following command:
Create a .htaccess at the root of the web site created in the steps referenced above and type in the following:
Modify the config.php file in the ‘system/application/config’ folder and remove the index.php reference off the $config[‘index_page’] entry.
Save the changes to the file and then go back to your browser and check to see that you can view your Codeigniter welcome page without the index.php file! If all goes well, you should see the same Welcome page that you saw when you first set up the web page.
After setting up Codeigniter, I would highly recommend that you read the user guide as this will give you a good idea of how Codeigniter works. The documentation is great as it’s very concise and easy to go thru.
Leave a comment