Monday, February 20

How to Install Codeigniter in Localhost

Codeigniter-Installation-Spicy-Loop
Codeigniter is a popular open source web application development framework created for php developers. It use the MVC (model-view-controller) Architecture pattern. The codeigniter framework offers many helpful code libraries and helpers to speed up development of php applications. In this tutorial we will show you how to install codeigniter in your localhost.

Requirement to start:

There are two things you need to start codeigniter installation in your localhost :
  1. Install a localhost server In your computer. There is many options e.g. wamp, xampp, lampp and you can download any of them. We will recommend you to use xampp server. Xampp server is a cross platform server application. Most of the web server companies use xampp. So when you go to upload your application on the web server you will use xampp.
  2. To start with codeigniter installation you have to download the codeigniter source file. If you have already downloaded codeigniter then you can get started with that. Other wise you can download it from their official website - https://www.codeigniter.com/download .You can also Download their Github repository from  - https://github.com/bcit-ci/CodeIgniter .

In this tutorial, we will go with 5 simple steps :
  1. Installing and Exploring CodeIgniter
  2. Configuring CodeIgniter
  3. Testing CodeIgniter
  4. Configuring Libraries and Helpers
  5. Configuring Database

 

Installing and Exploring CodeIgniter:

Once you download codeigniter from the provided download link you will receive a .zip file.Unzip and rename that folder as your project name.Now copy and pest that folder to your php and mysql server location.We are using Xampp server for making applications, so we copy it to the 'htdocs' folder of 'xampp'.If you are using Wamp server then you need to copy it to 'www' folder of 'wamp'.

 

Configuring CodeIgniter:

You need to set up the right base url to run your application. To set up a base url go to the location application>>config. Inside of the 'config' folder there will be a file 'config.php'. Open that file on your favourite text editor. Search for the bellow line.

$config['base_url'] = '';

Now copy and pest your application url inside of the single quote.As an example:

$config['base_url'] = 'http://localhost/your_project_folder_name';

 

Testing CodeIgniter:

Now we will check the CodeIgniter application is running properly or not. Open your application url from the browser. If your browser opens the bellow page it means your application running properly.

Codeigniter-Installation-Spicy-Loop

Configuring Libraries and Helpers:

Codeigniter provides two features to help programmers to create applications. One is library and other one is helper.Library class is a collection of tools and helper is a collection of functions in a particular category. You need to specify which library and helper you want to use in application.To do this go to the location application>>config and open 'autoload.php' file on your favourite text editor.Now search for the bellow line :

$autoload['helper'] = array();

Write the name of helper file inside of the array.As for example :
$autoload['helper'] = array('url', 'file');


Configuring Database:

To connect your codeigniter application with MySQL database go to the location application>>config and open 'database.php' file on your favourite text editor do the changes as bellow.

 $db['default'] = array(
 'dsn' => '',
 'hostname' => 'localhost',
 'username' => '',// Write your Database User Name inside of the single quote
 'password' => '',// Write Password of your Database User Name inside single quote
 'database' => '',// Write Database name inside of the single quote
 'dbdriver' => 'mysqli',
 'dbprefix' => '',
 'pconnect' => FALSE,
 'db_debug' => (ENVIRONMENT !== 'production'),
 'cache_on' => FALSE,
 'cachedir' => '',
 'char_set' => 'utf8',
 'dbcollat' => 'utf8_general_ci',
 'swap_pre' => '',
 'encrypt' => FALSE,
 'compress' => FALSE,
 'stricton' => FALSE,
 'failover' => array(),
 'save_queries' => TRUE
);

After connecting your codeigniter application with Database you are ready to perform database activities like insert, update, delete.

So this are the 5 simple steps to configure Codeigniter in your Localhost. Follow those 5 steps and start creating great applications.

We hope our tutorial on How to Install Codeigniter in Localhost will help you to get started with codeigniter.If this tutorial don't answer your question you can ask your question on the comment section bellow. We love helping our viewers to solve their problem.

If you liked this article, then please subscribe our newsletters for daily updates.