Download and Install Latest CodeIgniter Framework

Download and Install Latest CodeIgniter Framework:

You can Download and Install the Latest CodeIgniter Framework source code for the CodeIgniter framework is accessible on the official CodeIgniter site. In the event that you need to download the most recent version of the framework, at that point you ought to do it from the official page.

Step 1) Open the following URL in your browser https://codeigniter.com/ to download the latest version of CodeIgniter.

Step 2) Unzip CodeIgniter package.

Downloaded CodeIgniter that is available in zip format. Copy it and put it in your htdocs folder. Unzip and rename it. We are naming it as CodeIgniter.

Codeigniter Folder Structure

Step 3) CodeIgniter Welcome Page

On browser write this path -> localhost/CodeIgniter/ (after localhost type name of the folder that you unzipped). If the above screenshot view appears then it means your Codeigniter is successfully installed.

CodeIgniter Welcome Page

CodeIgniter Config Folder Structure

We have successfully installed CodeIgniter now let’s see the configuration directory

The configuration directory is located in application/config

Config Folder Structure

In application/config directory you will get below files:

  • autoload.php – specifies the helpers, libraries, drivers, packages, etc. that should be loaded when the application starts
  • config.php – contains application configurations such as base URL, language, query strings, etc.
  • constants.php – as the name suggests, this file I used to define application constants
  • database.php – contains database connection parameters
  • doctypes.php – defines document types i.e. html4, html5, sv10 etc.
  • foreign_chars.php – defines foreign characters that are to say characters that are found in languages such as Russian and others
  • hooks.php – allows you to define your own hooks
  • memcached.php – if you are using CodeIgniter together with Memcached then you can use this file for configurations.
  • migration.php – if you want to use database migrations in CodeIgniter then you can use this file to config the settings.
  • mimes.php – contains file mime types
  • profile.php – contains settings that are used by the built-in CodeIgniter compiler
  • routes.php – contains the application routes
  • smileys.php – contains settings for smileys
  • user_agents.php – contains settings for browser user agents, i.e., Chrome, Opera, Firefox, etc.

CodeIgniter Configurations

let’s now make some of the most used one settings in CodeIgniter

Open application/config/config.php

Base URL

$config[‘base_url’] = ”;

Sets the base URL. If its blank then CodeIgniter will set it for you automatically. If you want to be explicit about your base URL, then you can use the something like the following

$config[‘base_url’] = http://localhost/codigniter;

HERE,

  • $config[‘base_url’] = ‘http://localhost/codigniter’; sets the base URL to localhost running on CodeIgniter folder.

Other settings

  • They are so many settings that you can set in config.php such as date formats, cache and view paths, etc. what configuration you do it depends on your application needs.

How to remove index.php in CodeIgniter

CodeIgniter is an MVC framework. It means your application has an only single entry point and which is index.php it means you can access your application through index.php. It does not matter what URL you access. In your application, all things go through using index.php. By default, index.php is shown in the URL as shown in the example below

codeigniter.com/index.php?q=post

The above URL looks long and awkward. The good thing is you can configure CodeIgniter to remove that.

Open application/config/config.php and Locate the following line

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

Set it to the following

$config[‘index_page’] = ”;

  • We are going to use mod_rewrite to remove the index.php page so as per requirement, this should be set to blank.
  • Next, we need to create the .htaccess file that rewrites the URLs
  • Add a new file .htacces in the root directory of the application

Add the following code in .htacess file :

How To Remove Index.php From URL

 

  • The above code is for configuring web servers that run the apache server. The above code basically gets the URI parameters and executes them via index.php even if it’s not showing in the browser URL.