# CakePHP 4 Installation & Configuration

> Learn how to install CakePHP 4 using composer and XAMPP.

- URL: http://codethepixel.com/cakephp-4-installation-and-configuration
- Author: Asyraf Wahi Anuar (http://codethepixel.com/author/asyraf-wahi-anuar)
- Published: 2020-05-10
- Updated: 2021-11-02
- Category: CakePHP
- Tested with: CakePHP 4.x
- Tags: CakePHP, Installation
- Reading time: 3 min

This tutorial will guide you to install the CakePHP 4 using composer. The composer is a dependency manager. All developer is recommended to use composer as it is easier to maintain the codes and the framework package compared to the .zip archive. Database configuration is also included at the end of this tutorial.

## CakePHP 4 requirement

- HTTP Server. For example Apache. Having mod\_rewrite is preferred, but by no means required. You can also use Nginx, or Microsoft IIS if you prefer.
- Minimum PHP 7.2 (7.4 supported).
- mbstring PHP extension
- intl PHP extension (uncomment extension=php\_intl.dll in php.ini and restart the server)
- simplexml PHP extension
- PDO PHP extension

## Tools

- XAMPP with PHP 7.2 (minimum)
- Composer 1.10.6 or latest version

Install Composer. Download at [composer website](https://getcomposer.org/download/).  
Check PHP version using CLI

```bash
$ php-v
```

Make sure the PHP version is 7.2 and above.

## Download and create a CakePHP project

Execute the Command Prompt/ Windows Power Shell/ Git Bash and navigate the target directory to your htdocs path. If XAMPP is installed in C, then the command should be:

```bash
$ cd c:/xampp/htdocs
```

Then execute this command (myCake4 is your folder name - change to your own folder name):

```bash
$ composer create-project --prefer-dist cakephp/app:4.* myCake4
```

Composer will generate the myCake4 folder and download all CakePHP 4 source files:

> **Screenshot unavailable:** The original screenshot (composer-min.jpg) was lost when the old site moved. The text describes what it showed.

Once the download process is complete, navigate to localhost/myCake4 and it will redirect you to the main page for CakePHP 4.

> **Screenshot unavailable:** The original screenshot (cakephp-min.jpg) was lost when the old site moved. The text describes what it showed.

When this tutorial is written, the latest version of CakePHP 4 is 4.0.7. If you want to update your CakePHP 4 version, just navigate to the myCake4 path and run:

```bash
$ composer update
```

To update your database configuration, navigate to .../config/app\_local.php and edit the following codes (around line 37):

`config/app_local.php`

```php
'Datasources' => [
	'default' => [
		'host' => 'localhost',
		//'port' => 'non_standard_port_number',
		'username' => 'root',
		'password' => 'secret',
		'database' => 'yourDBname',
```

That all. Happy coding :)
