The recommended way to install CodeIgniter 4 is with Composer.
Requirements
- PHP 8.1 or newer (check the CodeIgniter docs for the exact version your release needs)
- PHP extensions intl and mbstring (on XAMPP, enable
extension=intlinphp.ini) - Composer
- MySQL / MariaDB (or another supported database)
Create a project
composer create-project codeigniter4/appstarter blog
Set up the environment
The project has a file named env. Copy it to .env and set:
CI_ENVIRONMENT = development— shows detailed errors while you buildapp.baseURL = 'http://localhost:8080/'
Lines in .env start with # when disabled — remove the # to use them.
Run the app
php spark serve starts a development server at http://localhost:8080. You will see the CodeIgniter welcome page.
Using XAMPP or WAMP
You can also put the project in htdocs and open the public folder (http://localhost/blog/public/), but php spark serve is simpler while learning.
Example
# 1. Create the project
composer create-project codeigniter4/appstarter blog
cd blog
# 2. Create your .env from the template
cp env .env # Windows: copy env .env
# 3. In .env, remove the # and set:
# CI_ENVIRONMENT = development
# app.baseURL = 'http://localhost:8080/'
# 4. Start the development server
php spark serve
# CodeIgniter development server started on http://localhost:8080
Open http://localhost:8080 to see the welcome page. Press Ctrl+C in the terminal to stop the server.