How to download Codeigniter and Basic set up on your computer

  • Post author:
  • Post category:CodeIgniter
  • Post comments:0 Comments
  • Post last modified:October 5, 2020
  • Reading time:5 min(s) read

Codeigniter is nothing but a framework of PHP. It follows the MVC(Model-View-Controller) architecture. Before you start learning CodeIgniter you have to have basic knowledge of object-oriented programming(OOP). If you don’t know what is object-oriented programming then don’t be panic watch our video tutorials on youtube named BeAppend. You will get to learn step by step from scratch. In this blog, I am going to discuss Codeigniter such as how to download Codeigniter and Basic set up on your computer? What to do? what not to do? Read the whole blog carefully and watch the video below for a better understanding. for source code comment below or you can mail us at [email protected]

So to download Codeigniter. It is the last upgraded and stable version and Codeigniter 4 is still under development, for development, always prefer the stable version because all bugs are fixed on this version and you will get community support easily.

After downloading the zip file extract it into C:\xampp\htdocs (if you are using windows operating system) after extracting rename the folder as per your project name. In this folder, you can see lots of files and folders. Keep in mind that Application, system, and Index.php these two folders and one file are important for you, and the rest of the files and folders you can delete it or keep it that is up to you.

download Codeigniter and Basic set up

we are all set now start your Xampp and then open your browser and write localhost/your project folder name/ then you will see something like the below picture.

download Codeigniter and Basic set up

Now create a controller in your project folder\application\controllers.php file (example: New_con.php). You can give name whatever you want but the first letter of the name has to be in Capital Letter and the class name will be the same as your file(or controller ) name see the code below:

<?php
/**
 * 
 */
class New_con extends CI_Controller
{	
public function __construct()
{
parent:: __construct();
$this->load->helper('url');		
}
public function index()
{
$this->load->view('a');
}
}
?>

CI_Controller is your parent class name it is pre-defined whenever you create a new controller it has to extend to CI_Controller.

public function __construct()
	{
		parent:: __construct();

		$this->load->helper('url');
		
	}

the above code is nothing but a constructor method/function here we can declare all the global methods and variables so that each and every method/function within the New_con class can access it.

$this->load->helper('url');

The above line of code is URL helper which we defined globally.

Then we create a function/method to load view/user interface/frontend as given below:

public function index()
	{
		$this->load->view('a');
	}

index() is just a function name you can give whatever you want. the public is just an access specifier .we all know there are three types of access specifiers private, protected, and public.

$this->load->view('a');

The above-mentioned code is used to load a view and “a” is the file name which you have to create in the views folder, to create a view you have to go to project folder\application\views\ .php (example: a.php) and write your HTML code as given below:

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="jumbotron text-center">
<h1>My First Bootstrap Page</h1>
<p>Resize this responsive page to see the effect!</p> 
</div>  
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3>Column 1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
<div class="col-sm-4">
<h3>Column 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
<div class="col-sm-4">
<h3>Column 3</h3>        
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
</div>
</div>
</body>
</html>

Thereafter, go to your project folder\application\config\config.php  put your base_url as given below:

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

In the above-mentioned code myci is my project folder name. In your case put your own folder name.

Now, to view your page in a browser you have to type your URL like this: localhost/ your project folder name/index.php/controller name/method name/ .for example http://localhost/myci/index.php/New_con/index.
we can remove index.php from the URL for that I have already made a different video on youtube click here.

Download Codeigniter and Basic set up on your computer are done. Please leave your suggestion on the comment box. to support us follow our social media links. Subscribe our youtube channel BeAppend. Follow on Instagram like your Facebook page.

Leave a Reply