21 Min Read

This is a CodeIgniter tutorial, which we will systematically introduce as a framework for the reader. You will learn how to install and configure CodeIgniter Hosting Hostinger along with building your first application using PHP, this concept is very common. You can also learn about MVC and why it is an important tool for advanced website development.


What is CodeIgniter

These days in the field of web design, modularity, and high performance. The day had to, again the same password for multiple applications or for a greater effort than necessary to build your dynamic application has passed. The framework is a modern website, yes, all for you.

CodeIgniter is a framework available to PHP programmers. Best known among its siblings as it accelerates web development in PHP through largely place packages and libraries. This library was designed for areas of web design where that code reuse, in general, goes forward, developers do a lot of work.

In the model-view-controller (MVC) architecture, CodeIgniter and adds a layer of logic to your web applications. This will help not only purer but also be useful in parallel, certain processes in the development period. As a result, the products will have a high reaction to market and business change possibilities more quickly.

All the requirements for this tutorial include basic knowledge of PHP, because of some kind of experience with the Linux command line.

What do you need

  • SSH access to VPS hosting or sharing
  • Nano or any text editor

Step 1 – CodeIgniter Installation

Install CodeIgniter, you need Hostinger or TERM hosting (Linux, Apache, MySQL, PHP) is already active and running VPS from the local system. You can control what is a tab on any Linux version, and of course, we are using Hostinger’s shared hosting account.

Firstly, you need to acquire an account, via SSH. You know what it is, for this tutorial, please.

To start the installation process, open the terminal and navigate to the public_html folder. In this case, run the following command:

cd /public_html

Now you need to download instructions for the latest version of CodeIgniter, You can do this by just going to the official website and downloading the zip file. With the creation of this tutorial the latest version of CodeIgniter is 3.1.4:

o wgetıgniter/archive/

To unzip the file, run the following command:


If installing CodeIgniter VPS, maybe you Zip installed on your system. In this case, the error may occur after executing the command. You can solve this problem by simply downloading and installing open, like this:

sudo apt-get install zip

You should now be unzipping a copy of CodeIgniter.

So, unzipped, you need to see the directory called CodeIgniter-3.1.4. You can change the name to make it easier, below if you want this step:

mv /var/www/CodeIgniter-3.1.4 /var/www/codeigniter

Now open your browser and enter the folder path. you should see the CodeIgniter default welcome screen. This means that CodeIgniter was successfully installed.

Step 2 – Install CodeIgniter

After installing your copy of CodeIgniter, you have to install it before anything else. Even, that is the most complex part of setup tutorials is only run once, saving you headaches in the future.

Start by creating a new MySQL database. The Hostinger you can make is a MySQL database system.

To start the installation process, you need to supply CodeIgniter with any information, MySQL database. You can do that, the database.php file variable in CodeIgniter. Open the file and run the following command:

nano /codeigniter/application/config/database.php

The contents of the file must be visible to you. Find for the next file session and include specific information to configure your MySQL database.

So the file is not updated with all the relevant information, save and close. And it’s not just about syncing your database with CodeIgniter.

Moving forward with our tutorials, you can now set up the domain registration. To do this, open the config.php file and one of the following options:

nano codeigniter/application/config/config.php

So, it opened, see the following command there and change it according to your needs.

$config[‘base_url’] = ‘’;

This line means that if there is how to register a domain, you are in the directory where CodeIgniter installed (the last command (Step 1), you must modify the config.php file to see, as in the line above.

2.1 Installing a VPS Motherboard

Skip this step if you are using CodeIgniter hosting Hostinger.

A virtual host can be useful if you run multiple programs with domain registration. This can help if your VPS and multiple apps, workplaces or others, are currently running. You can create the virtual machine with an Apache server.

While creating virtual machines, beyond the focus of this lesson, you can make some changes to CodeIgniter’s settings, before you officially begin development.

Firstly, you must make sure that your root document syncs the CodeIgniter installation directory. You can do this, the açaraqvail file your virtual host:

sudo nano /etc/apache2/sites-efficient/000-default

So that openly find the following block and insert it in the installation directory before the root document.

DocumentRoot /path/to/Codeigniter […….]

Be sure to change /path/to as instructed.

Now all the Url will display whatever you have installed on CodeIgniter. The following context change request. By default, CodeIgniter supports the following URL format:


As you can see, index.php is the only static URL. To better develop, we must get rid of them all.

Do this for, open the config.php file one more time:

nano codeigniter/application/config/config.php

And replace the following line:

$config[‘index_page’] = ‘index.php’;

This is:

$config[‘index_page’] = “;

Only half the job. Rest assured that you are bombarded with errors, you redirect these records, via the .htaccess file.

Before doing this, make sure the mod_rewrite included:

apache2ctl -M

This will make Apache list some server functionality. If you can find mod_rewrite in the list, please the following command. If you don’t find it, you can use this line:

a2enmod replace

And restart your web server.

sudo service apache2 restart

Now create the .edit the .htaccess file in the root folder of your CodeIgniter:

nano codeigniter/.htaccess

This allows you to create and open the .htaccess file. Type the following lines into the file, save it close:

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php?/$0 [PT,L]

Finally, what you need, Apache, knew that a new .htaccess file exists. To do this, open the mother virtual file one more time making sure AllowOverride is set to Everyone.

Options Indexes options follow symlinks MultiViews AllowOverride All Order allow, deny allow from all

Now you more worry about what bothers index.php a URL. It’s the Url for a cleaner look.

Read more: How to send email using PHP scripts

Step 3 – Understanding the MVC

In fact, aware that the framework, like CodeIgniter, is commendable that you have to spend some time, this is the guide to finding out more about MVC.

MVC is mainly the web development architecture paradigm, which states that any application, logic, needs to split into a view. It divides the application into three functional parts: model, view, and control.

The models do all the dirty work – they have the responsibility for handling databases, calculations, driving, etc. In short, this is where business logic is located. Vision, on the other hand, has nothing to do with the logic of its application. They form a layer in the application of data received in your models when the page is loaded. Controls are mandatory between models and the view. They forward the requests in their models, and therefore the model of service done, carries in it the vision of the real.

So that, CodeIgniter subscribes to object-oriented programs (OOP), all models and control receive classes from PHP extensions main classes, provided by the framework. The view is also important as PHP files, but only with the name, so that all your content is in HTML/CSS. Much is not a PHP code present, to show the information is given by a template.

MVC gives developers greater flexibility in terms of code reuse and design separation for development. It can be taken the view that there is not, to write the same code, view for, for example, for the navigation panel on all pages of the site. And because of its vision and model, there are separate entities, front-end developers can work in parallel with the back-end team to dramatically reduce total development time.

3.1 – Basic Routing Concepts

We’ve already seen how the CodeIgniter URL string format:


In the preview system, we learned, how to remove index.php from the format. As a result, the template will translate the Url as shown below:

Goodness here is a control class, the assigned control file welcome.php. Within that class, the checker() function, plus get and ‘1’ as a parameter. In any later version, the choice will be affixed so the image is separated by a slash.

As you see, then, the route is very easy for CodeIgniter. You can experiment, create routes, more sophisticated, but we won’t explore here.

3.2 Library

Another important function, CodeIgniter, is your incentive to reuse existing ones for common tasks quickly. This is CodeIgniter providing the library and auxiliary functions (wizards). This ColdIgniter competition is that developers can pick and select downloadable libraries where you can download them. As a result, quickly, easily, but still saturated with paper through the well-equipped library.

Downloading the library is very simple using CodeIgniter. Just the screen, below the model line


Some libraries and wizards, so often, really, it’s best to install them automatically when you load your site. Examples include the database library-the integral part of any web application, the modern and the URL helper, which can be useful for easier download from Url.

To download it automatically and in your Database library, open the file as follows:

nano application/config/autoload.php

So open to replace the following line:

$autoload[‘libraries’] = array();

This is:

$autoload[‘libraries’] = array(‘database’);

You automatically download one more library using the array() method, separated by a comma.

So, assistants, need to replace:

$autoload[‘helper’] = array();

This is:

$autoload[‘helper’] = array(‘url’);

Knowing more about MVC, we hope you can more deeply appreciate CodeIgniter’s multifaceted.


Step 4 – Create a Simple Application with CodeIgniter

With the correct clearance of strangers on the way, we finally get the tutorial treasury. At this point in our CodeIgniter tutorial, you should already be running a CodeIgniter version with all changes made, we are ready for Step 2. You should already be more familiar with how models, concepts, and elements work in CodeIgniter. In this session, we are going to use that knowledge to create a simple application.

The program is quite simple concerning design: we will use our template to capture the grid, movie reviews, in our database and show them with the help of our point of view. So, you’re already past, through the CodeIgniter fundamentals, you can go ahead and start building a bunch more rich apps.

Step 4.1 – Prerequisites

This preface this manual shows, it is necessary basic knowledge of MySQL readers. In our simple app you should create, tables, titles, comments with 3 column id name (primary key and auto-incremented), name, and grid.

You, to go ahead and create this table so that it became the basis and your application. It CodeIgniter must have access to your database if you correctly execute the Step 2 instructions. After creating the table, fill in the intermediate values.

Step 4.2 – Template

After working on your database, we can start accepting the business logic. To do this, let’s create a model that will receive the value from the database.

The template is placed in CodeIgniter’s Applications/Template folder. This is to avoid confusion that has been made in your directory structure. Go to the directory and create a new PHP file called reviews_model.php .


So, you created it, enter the following code in the file:

As you can see, in the classroom the Reviews_model model augments the CI_Model class made by CodeIgniter. It should also be noted that the first letter in your classroom is in an elevated area because CodeIgniter requires a capitalized approach.

Now you need to download the book, the Database, we can note that Step 3. This will make working with databases not very easy. You can use the methodu the builder, the model will be effective, download the library from the start. To do this, enter the code inside a class created below:

public function __construct() { $this->load->database(); }

Now the database, library, indicates itself, each method within a class. After doing this, we need to create another method is to use libraries, databases needed for the database.

public function get_reviews($id) { if($id != WRONG) { $query = $this->db->get_where(‘reviews’, array(‘id’ => $id)); return $query->row_array(); } else { return TRUE; } }

The above method is just takes the ID as an argument and returns all available data in columns related to this ID. So this method will be chosen for every time we need to review the movie.

Step 4.3 Control

We care about the information layer. Now we need a route, you need to create what, when a user looks for an analysis of a movie, our view will be created for the information we created using the template.

To create a new control item, go to the application/controllers directory and create a file named reviews.php. Remember: CodeIgniter Control must be, that the filename will be the same as the class defined within this file.

After creating the file, open it and enter the code below: All you need to do now is to collect the model information, and for vision realization. To do this, let’s create the so-called show() method that binds the data to this structure, which we just created, and from transfers, the view structures are passed to that.

public function show($id) { $this->load->model(‘reviews_model’); $traveler = $this->reviews_model->get_reviews($id); $data[‘title’] = $traveler[‘title’]; $data[‘grade’] = $traveler[‘grade’]; $this->load->view(‘movie_review’, $data); }

It is an array $data is an associative array, with name, partition, and the corresponding grid of values ​​obtained from the database. It’s the array, a view, the name movie_review, and from this point of view, the question is loaded.

The Step 4.4 Vision

Finally, let’s create a will show you analyze the selected movie.

Go into the application/views folder and create a new file named movie_review.php. Note that the filename must match the name, which you can set for the download control (the last line of the show() method ). After creating the file, enter the code below:

The view will only reveal the name, such as your grid, so they are sent to the serial control. $date. And I must say that the result is not very nice, for this reason, we do not, which probably no style, our opinion. Of course, you can add an inline style (recommended) or CSS style references, the view.

Our test application is completed. You can see the result when you type below the following address in the browser: This will allow access for the management, look that we created Step 4.3 and call the show() method with option 1, which is pasted. This parameter is perceived as a movie ID, it will be used, to get a movie database ID = 1. As a result, the user can see the name and summary of the first movie in a database.


So what is he! This is a CodeIgniter tutorial, we saw it, how to install and configure it, and also how to create a simple application using this framework. We also saw MVC, the guiding principle for CodeIgniter, and why it’s so important in modern web development.

And is our application for testing was very simple, just the look of the model, control, and database query, we hope you will serve the purpose of starting user, for your family, heart, CodeIgniter features.

Readers can now create the application, high dynamic, with CodeIgniter, faster than before, using the library and wizards.


for website maintenance service contact us.


Share this Article
Posted by Rebecca
Rebecca is an Independent content writer for breldigital, She writes content on any given topic. She loves to write a case study article or reviews on a brand, Be it any topic, she nails it
Leave a comment

Leave a Reply