CakePHP 3 Quick Install

Here’s a quick three-step process for doing a basic installation of CakePHP 3 when starting a new project.

Before starting, make sure the server is ready and PHP is installed:

  • HTTP Server (i.e. Apache) with mod_rewrite
  • PHP 5.5.9 or greater (including PHP 7)
  • mbstring PHP extension installed
  • intl PHP extension installed
  • Composer (included in your path so it can be accessed globally)

Also, since it’s likely a database will be part of the project, make sure one of the following is set up on the server and update php.ini accordingly:

  • MySQL (5.1.10 or greater)
  • PostgreSQL
  • Microsoft SQL Server (2008 or higher)
  • SQLite 3

Step 1: Create a project

Log in to the server, navigate to the public html directory, and create a new cakephp project with Composer using the following command, replacing app_name_goes_here with the project’s name:

composer create-project cakephp/app <app_name_goes_here>

More details about this build can be found on Github at

Don’t forget to check the composer.json file for any recommended downloads that should also be installed.

Now point your web browser to the project folder, and the CakePHP intro page should appear.

Step 2: Configure the Database Connection

Create a database to which the app can connect. I like to use the same name as the project.

Next, navigate to <projectName>\config\app.php and edit the datasource configurations as appropriate. The other settings can be left alone for now.

Now return to the browser and refresh the index page to confirm the database connection works as expected.

Step 3: Configure the Email Transport

Navigate to <projectName>\config\app.php and edit the email transport and delivery profile configurations as appropriate. The other settings can be left alone for now.

Next, return to the command line, navigate to the project folder, and bake a new shell to test this configuration:

$projectName bin/cake bake shell email

Return to the IDE, navigate to and open src/Shell/EmailShell.php, then add the following ‘use’ statement to the file as so:

namespace App\Shell;

use Cake\Console\Shell;
use Cake\Mailer\Email; // added

Go to the bottom of the file and add this new method as so:

    // added
    public function test()
        debug(Email::deliver('', 'Test Subject', 'Test Message', 'default'));

Now return to the command line and run the following command to test if the email transport is working:

bin/cake email test -v

If everything is working properly, this should output the test email directly to the console.

That’s it! CakePHP is now installed, tested, and ready to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.