Install CakePHP 4.x in Ubuntu

Installation

CakePHP has a few system requirements:

  • 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 (8.1 supported).

  • mbstring PHP extension

  • intl PHP extension

  • SimpleXML PHP extension

  • PDO PHP extension

In XAMPP, intl extension is included but you have to uncomment extension=php_intl.dll (or extension=intl) in php.ini and restart the server through the XAMPP Control Panel.

In WAMP, the intl extension is “activated” by default but not working. To make it work you have to go to php folder (by default) C:\wamp\bin\php\php{version}, copy all the files that looks like icu*.dll and paste them into the apache bin directory C:\wamp\bin\apache\apache{version}\bin. Then restart all services and it should be OK.

While a database engine isn’t required, we imagine that most applications will utilize one. CakePHP supports a variety of database storage engines:

  • MySQL (5.6 or higher)

  • MariaDB (5.6 or higher)

  • PostgreSQL (9.4 or higher)

  • Microsoft SQL Server (2012 or higher)

  • SQLite 3

The Oracle database is supported through the Driver for Oracle Database community plugin.

All built-in drivers require PDO. You should make sure you have the correct PDO extensions installed.

Installing CakePHP

Before starting you should make sure that your PHP version is up to date:

php -v

You should have PHP 7.2 (CLI) or higher. Your webserver’s PHP version must also be of 7.2 or higher, and should be the same version your command line interface (CLI) uses.

Installing Composer

CakePHP uses Composer, a dependency management tool, as the officially supported method for installation.

  • Installing Composer on Linux and macOS

    1. Run the installer script as described in the official Composer documentation and follow the instructions to install Composer.

    2. Execute the following command to move the composer.phar to a directory that is in your path:

      mv composer.phar /usr/local/bin/composer
      
  • Installing Composer on Windows

    For Windows systems, you can download Composer’s Windows installer here. Further instructions for Composer’s Windows installer can be found within the README here.

Create a CakePHP Project

You can create a new CakePHP application using composer’s create-project command:

composer create-project --prefer-dist cakephp/app:~4.0 my_app_name

Once Composer finishes downloading the application skeleton and the core CakePHP library, you should have a functioning CakePHP application installed via Composer. Be sure to keep the composer.json and composer.lock files with the rest of your source code.

You can now visit the path to where you installed your CakePHP application and see the default home page. To change the content of this page, edit templates/Pages/home.php.

Although composer is the recommended installation method, there are pre-installed downloads available on Github. Those downloads contain the app skeleton with all vendor packages installed. Also it includes the composer.phar so you have everything you need for further use.

Keeping Up To Date with the Latest CakePHP Changes

By default this is what your application composer.json looks like:

"require": {
    "cakephp/cakephp": "4.0.*"
}

Each time you run php composer.phar update you will receive patch releases for this minor version. You can instead change this to ^4.0 to also receive the latest stable minor releases of the 4.x branch.




Comments

Popular posts from this blog

CakePHP 4: Firebase Cloud Messaging Component in CakePHP for Push Notification

CakePHP 4 : Using Component inside Command ( Shell )

LIMIT SSH ACCESS BY COUNTRY