Setting Up CodeIgniter Environment

πŸ“˜ CodeIgniter πŸ‘ 33 views πŸ“… Dec 22, 2025
⏱ Estimated reading time: 2 min

Below is a step-by-step guide to setting up a CodeIgniter environment, focusing on CodeIgniter 4 (recommended for new projects).


1. System Requirements

Make sure your system has:

  • PHP 7.4 or higher (PHP 8.x supported)

  • Extensions enabled:

    • intl

    • mbstring

    • json

    • mysqlnd (for MySQL)

  • Composer (recommended)

  • Web server: Apache / Nginx / XAMPP / WAMP / Laragon


2. Install CodeIgniter 4

Option A: Using Composer (Recommended)

composer create-project codeigniter4/appstarter myproject

Then move into the project:

cd myproject

Option B: Manual Download

  1. Download from the official CodeIgniter website

  2. Extract the files

  3. Rename the folder (e.g., myproject)


3. Configure Environment File

Rename .env file:

cp env .env

Open .env and set:

CI_ENVIRONMENT = development

4. Set Base URL

Edit:

app.baseURL = 'http://localhost:8080/'

5. Database Configuration

Edit .env:

database.default.hostname = localhost database.default.database = mydb database.default.username = root database.default.password = database.default.DBDriver = MySQLi

6. Run Development Server

Use CodeIgniter’s built-in server:

php spark serve

Visit:

http://localhost:8080

You should see the CodeIgniter welcome page ????


7. Folder Permissions

Make sure these folders are writable:

writable/ β”œβ”€β”€ cache β”œβ”€β”€ logs └── uploads

8. Enable Error Reporting (Development)

In .env:

CI_ENVIRONMENT = development

Errors will now be displayed clearly.


9. Apache Configuration (Optional)

Enable mod_rewrite and use .htaccess:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

10. Verify Installation

Create a test controller:

php spark make:controller Test

Edit:

public function index() { return "CodeIgniter is working!"; }

Visit:

http://localhost:8080/test

Common Issues & Fixes

IssueSolution
Blank pageCheck PHP version
404 errorBase URL or routes misconfigured
Composer not foundInstall Composer & add to PATH

πŸ”’ Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes