CodeIgniter 4 – Creating a “Hello World” application

This tutorial shows you how to create your first CodeIgniter 4 “Hello World” application.

Table of contents:

  1. CodeIgniter 4 Requirements
  2. Install CodeIgniter 4
  3. Create Hello World Controller
  4. Create Hello World View
  5. Run Your First Hello World Controller

1. CodeIgniter 4 Requirements

CodeIgniter 4 requires PHP 7.3 or higher and intl and mbstring extension installed on your web server.

And the following PHP extensions are also recommended to be enabled on your server: php-json, php-mysqlnd, php-xml.

It also currently has supported for the below database:

  • MySQL (5.1+) via the MySQLi driver
  • PostgreSQL via the Postgre driver
  • SQLite3 via the SQLite3 driver


2. Install CodeIgniter 4

CodeIgniter4 can be installed via Composer or Manually. Choose Manual installation way if you would like to “install & go” install. Choose Composer installation if you plan to use 3rd party composer packages in your project or want to keep CodeIgniter up to date easily. We would like to recommend you to use Composer installation.

  • Manual installation

You can download and unzip the CodeIgniter 4 package on this page.

  • Composer installation (recommended)

Make sure that you have installed composer in your development machine. If you do not have it yet, you can install it by following the instructions on this page.

Then, use the following composer create-project command to install CodeIgniter 4.

composer create-project codeigniter4/appstarter MyFirstCodeIgniter4App

3. Create Hello World Controller

Create Helloworld.php file in app/Controllers/ directory and add the following content.

<?php namespace App\Controllers;

class Helloworld extends BaseController
    public function index()
        return view('Helloworld/index');

In the index() method, we load Helloworld’s index view which we will create right below (in step 4).

4. Create HelloWorld View

In app/Views/ directory, let’s create Helloworld/index.php as below.

    <title>My First CodeIgniter Application</title>
    <h1>Hello, World!</h1>


5. Run Your First Hello World Controller

First we need to start CodeIgniter Development server by running the following command in the root project:

php spark serve

Now visit your site using this URL.


If you did it right, you should see “Hello, World!” in your web browser.

Hello, World!