Skip to content
CODE THE PIXEL
CakePHP

CakePHP 4 Installation & Configuration

Asyraf Wahi Anuar Updated 3 min read

Learn how to install CakePHP 4 using composer and XAMPP.

This tutorial may be outdated

It was last reviewed 4 years ago. Some steps may differ in newer versions.

Tech stack

  • CakePHP 4.x

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.
Check PHP version using CLI

Terminal
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:

Terminal
cd c:/xampp/htdocs

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

Terminal
composer create-project --prefer-dist cakephp/app:4.* myCake4

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

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

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:

Terminal
composer update

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

config/app_local.phpPHP
'Datasources' => [
	'default' => [
		'host' => 'localhost',
		//'port' => 'non_standard_port_number',
		'username' => 'root',
		'password' => 'secret',
		'database' => 'yourDBname',

That all. Happy coding :)

Did this tutorial help?

214 readers found this helpful

Comments

No comments yet. Questions about this tutorial are welcome here: the answer helps the next reader too.

Leave a comment

Markdown works: `code`, ``` blocks, **bold**, links.

First comments are reviewed before they appear.

CakePHP

Using Bahasa Melayu Table Names in CakePHP

Learn how to use Bahasa Melayu table names like "pengguna" in CakePHP while following the framework’s naming conventions. Includes tips for using the Bake tool and avoiding pluralization issues.

5 min read

Tools & Software

Formatting PHP in VSCode Using Prettier and PHP Intelephense

Learn how to set up Visual Studio Code (VSCode) for automatic PHP file formatting using the Prettier and PHP Intelephense extensions. This step-by-step tutorial will help you maintain a clean and organised codebase, enhancing your PHP development experience.

2 min read