CodeIgniter is a web application framework for PHP. It enables developers to build web applications faster than writing it from the scratch. It provides us rich set of libraries and helpers for commonly needed task.
In this tutorial, you are going to be shown basic how to set up the framework, include how to build basic hello world using the MVC approach. MVC is an architectural pattern used in software engineering which stands for Model, View and Controller.
- Model deals with database interaction and contains functions like inserting/deleting records to a database or selecting specific database records.
- View deals with displaying the data, and while
- Controller controls what is sent to the view from the model. In CodeIgniter, the controller is also the place to load libraries and helpers.
In order to start, we will need to download CodeIgniter and upload it to your local/remote server. Direct your browser to CodeIgniter and click the large download button. For this tutorial we are using CI version 2.0.3
Once we have downloaded CodeIgniter, all we need to do is to extract it, and rename the folder either to codeigniter or to whatever you prefer. I personally like to name it as application with prefix ci_ e.g ci_tutorial1. In my case, I am using web server for localhost, so I upload into Xampp’s htdocs folder and only application, system folder and index.php file and it will look like
Expand the application folder. We will find many folders, for simplicity sake our concern are only config, controller and views folders.
Now, for development step, we will use Netbeans 7.01 as IDE, but feel free to choose whatever IDE you like even as simple as notepad.
- Open your Netbeans, and click New Project or Ctrl+Shift+N
- Choose PHP application with Existing Source as your new Project then browse folder that we already created before in htdocs and click next until we are done.
When we execute to see if our CI is up and running properly. Go to http://localhost/ci_tutorial1/ or right click on the project->run and we should see the following.
If we are up and running, now we need to modify the welcome_message.php in the view’s folder. Replace with
we should see something like this below
We are Finito!