This article explains how to install the CakePHP web framework on Ubuntu 24.04.
CakePHP is an open-source web application framework written in PHP. It helps you build web applications by providing a structured framework that follows the Model-View-Controller (MVC) architectural pattern.
The framework includes an Object-Relational Mapping (ORM) system that simplifies database interactions, allowing you to work with objects instead of raw SQL queries.
Once all the necessary components are installed, like PHP, a web server (like Apache or Nginx), and Composer, you can create a new CakePHP project using Composer, which is well-documented and easy to follow.
Install PHP requirements
CakePHP uses PHP language. You will to have PHP on your machine to use CakePHP.
Run the command below to install some necessary PHP related packages.
sudo apt update
sudo apt install composer php8.3-curl php8.3-sqlite3 php8.3-xml php8.3-mysql
Once PHP is installed, open its configuration file. PHP 8.3 is the current version available in Ubuntu 24.04 as of this writing.
sudo nano /etc/php/8.3/cli/php.ini
When the file opens, change the highlighted line.
# line 1614: adjust the value
; Default Value: 1
; Development Value: 1
; Production Value: -1
; https://php.net/zend.assertions
zend.assertions = 1
;
;
Save and exit.
Create CakePHP project
With PHP packages installed, run the command below to create a CakePHP project folder.
mkdir project
Change into the project folder and create your CakePHP app.
cd project
composer create-project cakephp/app MyApp
If everything works, you should see an output similar to the one below.
Permissions set on /home/richard/project/MyApp/tmp/cache
Permissions set on /home/richard/project/MyApp/tmp/cache/models
Permissions set on /home/richard/project/MyApp/tmp/cache/persistent
Permissions set on /home/richard/project/MyApp/tmp/cache/views
Permissions set on /home/richard/project/MyApp/tmp/sessions
Permissions set on /home/richard/project/MyApp/tmp/tests
Permissions set on /home/richard/project/MyApp/tmp
Permissions set on /home/richard/project/MyApp/logs
Updated Security.salt value in config/app_local.php
Change to MyApp folder and run CakePHP.
cd MyApp
./bin/cake server -H 0.0.0.0 -p 8765
Open your browser and browse the server’s hostname or IP address followed by port # 8765.
Welcome to CakePHP v5.1.6 Console
-------------------------------------------------------------------------------
App : src
Path: /home/richard/project/MyApp/src/
DocumentRoot: /home/richard/project/MyApp/webroot
Ini Path:
-------------------------------------------------------------------------------
built-in server is running in http://0.0.0.0:8765/
You can exit with `CTRL-C`

That should do it!
Conclusion:
In summary, installing the CakePHP framework on Ubuntu 24.04 involves several straightforward steps:
- Install PHP and required packages: Ensure PHP and necessary PHP extensions are installed using the appropriate commands.
- Configure PHP settings: Modify the PHP configuration file to enable assertions for better error handling.
- Create a project directory: Set up a dedicated folder for your CakePHP project.
- Use Composer to create a CakePHP application: Easily generate a new CakePHP application within the project directory.
- Run the application: Start the CakePHP server and verify it by accessing the designated port in your web browser.
By following these steps, you can have your CakePHP web application up and running efficiently. Enjoy building your application!
Leave a Reply