You are here
Home > CakePHP > How To Install CakePHP 3 Using Composer (step by step)

How To Install CakePHP 3 Using Composer (step by step)

How to install CakePHP 3 using composer

Installation of CakePHP 3 is tricky or difficult for the beginner. I will be able to provide you with step by step directions to install  CakePHP 3 on your computer, All you wish to try and do is simply follow this tutorial

 

Requirements :

  1. Must you have installed PHP 5.6 or above on your computer
  2. Must be enabled mbstring extension and intl extension to install CakePHP 3 on your computer.
  3. PHP Lamp(Xampp or Wamp) Server Must be install on your computer or server.

 

For XAMPP Server intl extension is already installed, you need to enable this extension to uncomment below the line in your php.ini file. Php.ini file is located at c:\xampp\php\php.ini or where you have installed XAMPP.

Before uncomment:

;extension=php_intl.dll 
;extension=php_mbstring.dll

After uncommenting:

extension=php_intl.dll 
extension=php_mbstring.dll

After uncommenting above line you must restart your XAMPP server using XAMPP control panel.

For WAMP Server, the intl extension is enabled by default. But to make it work you have to go to php folder (by default) C:\wamp\bin\php\php{version}, copy all the files that look like icu*.dll and paste them into the Apache bin directory C:\wamp\bin\apache\apache{version}\bin. Once you completed please restart WAMP server.

 

Installing CakePHP 3 Framework:

CakePHP 3 uses  the composer to install, its dependency elements, and will some automatic configuration work for you. So to install CakePHP 3 you want to have composer installed on your computer.

How to install composer:

Composer Installation for windows users is extremely simple. All you would like to try and do is simply download .exe installer file from the official website or click here to direct download.

You can also install the Composer using curl using below command.

curl -s https://getcomposer.org/installer | php

After successfully installed the composer, then type composer and press enter in the terminal you will be showing the response like in the below image.

 

How to install CakePHP 3:

Before install to CakePHP 3 using Composer, You should be in htdocs folder to start CakePHP 3 download. In htdocs folder Shift+Right click and choose “Open command window here” option. Like below image.

 

You can use other option for go to folder with cd command:

cd C:\xampp\htdocs

Now you can run the following command using your terminal window.

composer create-project --prefer-dist cakephp/app codex

It will take some time if you installing CakePHP first time using Composer. The second time it takes from the cache.

Last, of the installation process it will ask you to set permission for temp directory and to generate security salt. So please give Y to set the permission and generate security salt.

Finally successfully installed CakePHP 3 on your computer. So go to the project URL (http://localhost/codex/) on your browser to see CakePHP default home page.

How to change database  setting :

1. Open app.php file from config folder.

2. Find Datasources array in the file.

'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false, 'host' => 'localhost', /** * CakePHP will use the default DB port based on the driver selected * MySQL on MAMP uses port 8889, MAMP users will want to uncomment * the following line and set the port accordingly */
//'port' => 'non_standard_port_number',
            'username' => 'root',
            'password' => '',
            'database' => 'myDatabase',
            'encoding' => 'utf8',
            'timezone' => 'UTC',
            'flags' => [],
            'cacheMetadata' => true,
            'log' => false,
            /** * Set identifier quoting to true if you are using reserved words or * special characters in your table or column names. Enabling this * setting will result in queries built using the Query Builder having * identifiers quoted when creating SQL. It should be noted that this * decreases performance because each query needs to be traversed and * manipulated before being executed. */
            'quoteIdentifiers' => false, /** * During development, if using MySQL < 5.6, uncommenting the * following line could boost the speed at which schema metadata is * fetched from the database. It can also be set directly with the * mysql configuration directive 'innodb_stats_on_metadata = 0' * which is the recommended value in production environments */
            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
            'url' => env('DATABASE_URL', null),
        ]
    ]

3. Change database name, username, password.

Enjoy!!

Leave a Reply

Top