CodeIgniter Installing CodeIgniter



📝 Installing CodeIgniter

🔎 Introduction

CodeIgniter is a lightweight PHP framework known for its speed and simplicity. Before you start building applications, you need to set up CodeIgniter properly on your system.

This guide covers the different installation methods:

  • Manual installation (download and extract)

  • Installation using Composer

  • Setup on XAMPP/WAMP/LAMP


📥 1. Download CodeIgniter

You can download CodeIgniter in two ways:

🔗 Official Website

💻 Using Composer (Recommended)

If Composer is installed on your system:

composer create-project codeigniter4/appstarter project-name

👉 This creates a new folder project-name with CodeIgniter installed.


🗂️ 2. Folder Structure After Installation

Once extracted or installed, your CodeIgniter project will look like this:

project-name/
├── app/            # Application folder (controllers, models, views)
├── public/         # Public index.php (entry point)
├── system/         # Core framework files
├── writable/       # Cache, logs, sessions
├── .env            # Environment settings
├── composer.json   # Dependencies
  • app/ → Your application logic (controllers, models, views).

  • system/ → Core CodeIgniter files (do not edit).

  • public/ → The entry point (index.php).


⚙️ 3. Configure Base URL

Open app/Config/App.php and set your base URL:

public string $baseURL = 'http://localhost:8080/';

If you’re using XAMPP/WAMP, it may look like:

http://localhost/project-name/public

▶️ 4. Running CodeIgniter

🔹 Using Built-in PHP Server

Navigate to your project folder and run:

php spark serve

👉 Your app will run at: http://localhost:8080/

🔹 Using XAMPP/WAMP

  1. Place your project in the htdocs/ (XAMPP) or www/ (WAMP) folder.

  2. Start Apache & MySQL.

  3. Access:

http://localhost/project-name/public

🛠️ 5. Verifying Installation

If installed correctly, you’ll see the CodeIgniter Welcome Page in your browser. 🎉


🚀 Alternative: Installing CodeIgniter 3

For legacy projects, you can install CodeIgniter 3:

  • Download from CodeIgniter 3 GitHub

  • Extract into your server directory.

  • Open application/config/config.php and set:

$config['base_url'] = 'http://localhost/project-name/';

🎯 Conclusion

Installing CodeIgniter is simple whether you use Composer or download manually.

  • Beginners: Start with manual installation (easy setup).

  • Advanced developers: Use Composer for better dependency management.

Once installed, you can begin creating controllers, models, and views to build your first CodeIgniter application.