Installation & Setup

CakePHP projects are created and managed with Composer, the same dependency manager covered in the Composer track on this site. If you're comfortable with composer create-project already, installing CakePHP will feel familiar — it's the exact same command, just pointed at a different package.

Creating a New Project

Open a terminal in the folder where you want your project to live and run:

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

This downloads the CakePHP skeleton application and all of its dependencies into a new my_app_name folder. If you followed the Composer track, this should look immediately familiar — composer create-project is a generic Composer feature for bootstrapping new projects from a template package, and CakePHP simply ships one.

Tip: If you're new to composer create-project, revisit the Composer track's lesson on it before continuing — everything here builds directly on that.

The Generated Folder Structure

Once Composer finishes, you'll have a new application with a predictable layout. This is the same convention-driven structure referenced throughout this track.

PathWhat it holds
config/Configuration files — database settings, routes, app-wide options
src/Controller/Controller classes that handle incoming requests
src/Model/Table and Entity classes that represent your data
templates/View template files that render HTML output
webroot/The public document root — the only folder your web server should point at
bin/cakeThe CakePHP console tool, used for running the dev server, generating code, and more

Starting the Development Server

CakePHP ships with a built-in development server, so you don't need Apache or Nginx configured just to start experimenting. From inside your project folder, run:

bin/cake server

By default this starts serving your application at http://localhost:8765. Open that address in a browser and you should see the CakePHP welcome page confirming everything is wired up correctly.

A Look Ahead: Code Generation with Bake

CakePHP includes a code-generation tool called Bake, run via bin/cake bake. Once your database connection is configured, Bake can inspect your tables and scaffold matching controllers, models, and templates for you automatically. You won't need it to follow along with this track, but it's worth knowing it exists — it can save a lot of typing once you're building real applications.

bin/cake bake all articles
Note: This website's own project doesn't have CakePHP installed, so these commands aren't run live on this page — copy them into your own project's terminal to try them out.
Next steps: Now that your project exists, head to MVC Architecture to see how CakePHP organizes the code you'll write inside it.