CakePHP 4 Installation & ConfigurationAsyraf Wahi Anuar - May 10, 2020
Estimated reading time: 1 minute, 33 seconds
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
- XAMPP with PHP 7.2 (minimum)
- Composer 1.10.6 or latest version
Install Composer. Download at composer website.
Check PHP version using CLI
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:
Then execute this command (myCake4 is your folder name - change to your own folder name):
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:
To update your database configuration, navigate to .../config/app_local.php and edit the following codes (around line 37):
'Datasources' => [ 'default' => [ 'host' => 'localhost', //'port' => 'non_standard_port_number', 'username' => 'root', 'password' => 'secret', 'database' => 'yourDBname',
That all. Happy coding :)