Basic Tutorial on Using CodeIgniter

In this tutorial, the author will provide a tutorial on the basic use of the PHP framework, namely CodeIgniter. The author uses CodeIgniter v 2.1.4 which can be downloaded directly from the official CodeIgniter web, namely http://ellislab.com/codeigniter. What you need for this tutorial is:

  1. CodeIgniter 2.1.4
  2. Text Editor (Sublime Text, CodeIgniter, Brackets, etc.)
  3. XAMPP / WAMP

PHP CodeIgniter Framework
PHP CodeIgniter Framework

What is done for the first time is to download CodeIgniter v 2.1.4 which has been provided on the official website and then extract the results of the download and generate a CodeIgniter folder. The folder must be moved into the htdocs folder in the XAMPP / WAMP directory.

Related Article: Codeigniter Initial Setup

After that, the reader must run the web server on XAMPP / WAMP in order to run the PHP script. If so, the reader can directly open the browser page and then write “localhost/CodeIgniter” in the Browser URL (without the quotes “”), if the “Welcome to CodeIgniter” display appears, it means that you have successfully used the CodeIgniter framework for the first time.

Welcome Page CodeIgniter
Welcome Page CodeIgniter

Before we discuss how this page can appear, readers should know that the CodeIgniter framework has an MVC / Model View Controller structure so that if you look at the contents of the application folder in CodeIgniter that was downloaded earlier there will be a models, views and controllers folder. (For those who do not understand the MVC programming model, you can read here: http://en.wikipedia.org/wiki/Model–view–controller)

Folder Structure in CodeIgniter
Folder Structure in CodeIgniter

Let’s take a look at the routes.php file in the application/config folder, in that folder there is code like this:

[php]$route[‘default_controller’] = “welcome”;[/php]

-> this code shows that the default controller or the first controller to run when running our web application is the welcome.php file which is in the controllers folder. Readers can change the default controller according to their wishes later, be patient, hehehe

From there we already know that when the website is first run (when we type localhost/CodeIgniter) it will run the welcome.php file which is in the application/controllers folder. Inside the welcome.php file contains: