Recommended WordPress Theme

Codeigniter 4 Installation

1 month ago by Tamas

In this tutorial we will learn how to install Codeigniter 4 on XAMPP. Codeigniter is an easy-to-use, lightweight PHP framework.

Before we start we will need to download XAMPP, which is a cross-platform web server package that comes with a combination of free open source softwares that helps you to build a local server on your computer. You can download XAMPP here. To install XAMPP you only need to download the installer and install it like any other softwares on your computer.

The second software you will need is obviously Codeigniter 4 which can be downloaded from here.

Once XAMPP is installed go to its “htdocs” folder and create a new folder there called “ci4”. Copy the content of the downloaded codeigniter file into this folder. Your folder structure should look like this:

Make sure that in the XAMPP control panel the Apache and MySQL modules are running.

Codeigniter 4 can be run in multiple ways. The easiest is using its built-in local development server.

If you are on a MAC, open your terminal or the command prompt if you are on a Windows machine. Navigate to the folder where you previously copied the Codeigniter files. Once you are in, type the following command:

php spark serve

This command will fire up Codeigniter’s server and you can now view your application in your browser by going to this address: http://localhost:8080.

You should see something like this:

While you are at it, you should also set you base URL. You can do this by going to "app/Config/App.php" and look for this line:

public $baseURL = '';

add your main URL here.

It's also a good idea to add the details of your database in "app/Config/Database.php". Look for:

public $default = [
  'DSN'      => '',
  'hostname' => 'localhost',
  'username' => '',
  'password' => '',
  'database' => '',
  'DBDriver' => 'MySQLi',
  'DBPrefix' => '',
  'pConnect' => false,
  'DBDebug'  => (ENVIRONMENT !== 'production'),
  'cacheOn'  => false,
  'cacheDir' => '',
  'charset'  => 'utf8',
  'DBCollat' => 'utf8_general_ci',
  'swapPre'  => '',
  'encrypt'  => false,
  'compress' => false,
  'strictOn' => false,
  'failover' => [],
  'port'     => 3306,
];

 

Edit the hostname, username, password, and database details.

SHARE:

Subscribe to our newsletter!

Get the latest tutorials and articles right into your inbox!


0 comment

LEAVE A REPLY

Your email address will not be published. Required fields are marked *

Sign In

Not a member yet? Register here!

Search

Web Hosting

Recommended Web Hosting

Get Sendy

Recommended Newsletter Software