Ubuntu 20.04 is the new LTS of this popular operating system. Therefore, it will be installed by many developers worldwide because it is free but being Linux it has all the tools available for web development. So today I will show you how to install CakePHP on Ubuntu 20.04
What is CakePHP?
CakePHP is a PHP framework for web application development. It is known to be one of the easiest to learn. However, do not be fooled by its ease of learning, it is also one of the most powerful.
As expected, CakePHP is open source and is compatible with both Apache and Nginx. It also supports various database managers such as MySQL, MariaDB, SQLite, or PostgreSQL.
From the moment you access the CakePHP website, you will realize that it is a very pragmatic framework. This is because developers prefer conventions over configurations. So, you just have to set up the database connection and that’s it. No complicated setups.
Moreover, CakePHP is licensed under the MIT license which makes it perfect for use in commercial applications.
If you are starting in web development with PHP, CakePHP can be a great decision. So, let’s go for it.
Install CakePHP on Ubuntu 20.04
To start developing an application with CakePHP, you do not need to have a LAMP or LEMP installed, just the database manager and PHP. However, when your application is finished, you will need to install the webserver.
On the other hand, CakePHP requires certain PHP modules to run properly and should be installed:
php php-pdo php-intl php-xml php-zip php-mbstring phpunit php-mysql php-sqlite3
Install Composer on Ubuntu 20.04
CakePHP’s official installation method is through Composer. Thanks to Composer we can manage the dependencies of our PHP project and in this case install CakePHP.
So the first natural step is to install Composer.
If you want to know more about Composer you can also read this post:
Once Composer is installed and correctly configured for use on the system, we can continue.
Getting CakePHP on Ubuntu 20.04
Using Composer it is quite simple to install CakePHP. To do so, just run this command:
:~$ composer create-project --prefer-dist cakephp/app myproject
Replace myproject with your project name.
Then, the download of the dependencies will start as well as the installation. In the final part of the installation, you will be asked to change the permissions of the folders.
Then, access the project folder which in this case is called myproject and give execution permissions to the
cake file in the
:~$ cd myproject/ :~$ chmod +x bin/cake
If, for whatever reason, you cannot change the permissions of the
bin/cake file, you can run the CakePHP console with:
:~$ php bin/cake.php
However, it is unlikely that we will have to use this method.
To check that CakePHP is properly installed, simply run PHP’s built-in webserver to serve our project.
Remember that this is done for development purposes and never for production. And in this case, it will let us know if CakePHP is properly installed.
To do so, run the following command:
:~$ bin/cake server
This will make it available at
http:/localhost:8765. However, we can change these parameters and even the port:
:~$ bin/cake server -H 192.168.250.20 -p 1233
Again, remember that the host can be an IP address or a domain name. Also, the port has to be available on the firewall.
Then, open your web browser and go to the address specified along with the port and you will see something like this:
This indicates that CakePHP is ready to start development.
Web development is very important nowadays and for PHP it seems to be the most used and important language. It also has the advantage of having many important frameworks to be used as CakePHP. In this sense, installing CakePHP is quite simple and provides us with a great tool ready for work.
Please share this post and join our Telegram channel.