CakePHP Tutorial
CakePHP is a full-featured PHP MVC framework built around one core idea: convention over configuration. If you name your files, classes, and database tables the way CakePHP expects, most of the wiring — routing, model loading, view rendering — happens automatically, with almost no configuration required.
Where this fits: CakePHP is a bigger step up from Core PHP than Slim was — it comes with its own ORM, form helpers, and validation built in, rather than you assembling pieces yourself. Composer knowledge from the Composer track is assumed here too.
Convention Over Configuration
| If you have this... | CakePHP automatically assumes... |
|---|---|
A database table named articles | A Table class named ArticlesTable |
A controller named ArticlesController | Uses the Articles model automatically |
An action method named view() | Looks for a template at templates/Articles/view.php |
A URL like /articles/view/5 | Routes to ArticlesController::view(5) — no manual route needed |
A Quick Look Ahead
Example: A Minimal Controller Action
<?php
namespace App\Controller;
class ArticlesController extends AppController
{
public function index()
{
$articles = $this->Articles->find()->all();
$this->set('articles', $articles);
}
}
Note: This is correct, real CakePHP code — but this website's own project doesn't have CakePHP installed, so you won't see it actually run on this page. Follow along in your own project after the next page's installation steps.
Why Learn CakePHP?
| Reason | What it means for you |
|---|---|
| Fast to build with | Conventions mean less boilerplate and configuration than many frameworks |
| Built-in ORM | Query, save, and validate data without writing raw SQL for common cases |
| Batteries included | Form helpers, security features, and validation ship with the framework |
| Mature and stable | Long-running project with a strong upgrade path and active community |
Next steps: Head to Installation & Setup to create your first CakePHP project via Composer.