Cakephp framework: Setup new project

Here is the step by step note for the first web application with Xampp Server and Cakephp framework in local machine.

 

Install XAMPP for Window to prepare:

  • WebServer Apache.
  • PHP 5.6.0 (CLI) or higher.
  • MySQL database.

Install Composer for Window (https://getcomposer.org/download/). htdocs folder is recommended to install composer in.

Enable extension “intl” in your php.ini file.

Use cmd (change to htdocs folder ), create your own project with command:

composer self-update && composer create-project --prefer-dist cakephp/app yourprojectname

Be sure you accept security at the end of this installing process like this:

“Set Folder Permissions ? (Default to Y) [Y,n]? y
Updated Security.salt value in config/app.php”

Double check your installation in the htdocs\yourprojectname folder have structure like this:

/cms
  /bin
  /config
  /logs
  /plugins
  /src
  /tests
  /tmp
  /vendor
  /webroot
  .editorconfig
  .gitignore
  .htaccess
  .travis.yml
  composer.json
  index.php
  phpunit.xml.dist
  README.md

In cmd, move to htdocs\yourprojectname\bin, and execute:

cake server

Open your Web browser and hit “http://localhost:8765” to see the test homepage.

Be sure everything is green except the database still is red.

Create your database (ex: yourdatabase) in mySQL.

Edit your yourprojectname/config/app.php file with your database infomation

<?php
return [
    // More configuration above.
    'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            'username' => 'cakephp',
            'password' => 'AngelF00dC4k3~',
            'database' => 'yourdatabase',
            'encoding' => 'utf8mb4',
            'timezone' => 'UTC',
            'cacheMetadata' => true,
        ],
    ],
    // More configuration below.
];

 

Refresh Web browser  “http://localhost:8765&#8221; to check the database must be green.

If it is OK, congratulation!