Cakephp
# CakePHP 4.x Framework Guide
This file is automatically included by the motspilot pipeline when `FRAMEWORK="cakephp"` is set in config. It provides framework-specific knowledge for all pipeline phases.
<framework_tool_affinity>
CakePHP-specific tool routing:
- Use `bin/cake bake migration` to scaffold migration files — never handwrite migration boilerplate from scratch.
- Use `bin/cake bake model` to scaffold Table/Entity pairs — then customize. Never write a Table class without baking first.
- Use `bin/cake routes` to verify route conflicts before adding new routes.
- Use `bin/cake schema_cache clear` after migration changes.
- For constant values: grep `src/Model/` for existing constants before defining new ones.
</framework_tool_affinity>
---
## Version Reference
**This guide is for CakePHP 4.x. Do NOT use CakePHP 5.x APIs.**
| What | CakePHP 4.x (correct) | CakePHP 5.x (WRONG — don't use) |
|------|----------------------|---------------------|
| Custom finder params | `(Query $query, array $options)` | `(SelectQuery $query)` |
| Query class | `Cake\ORM\Query` | `Cake\ORM\Query\SelectQuery` |
| Query ORDER BY | `->order(['col' => 'ASC'])` | `->orderBy()`, `->orderByAsc()`, `->orderByDesc()` |
| Query GROUP BY | `->group(['col'])` | `->groupBy()` (on Query — fine on Collection) |
| Query select extra | N/A | `->selectAlso()` |
| Table loading (controllers) | `$this->fetchTable('Name')` (4.3+) or `$this->getTableLocator()->get('Name')` | Only `$this->fetchTable()` |
| Auth | AuthComponent or Authentication plugin (check which the project uses) | Authentication plugin only |
| CSRF | `CsrfProtectionMiddleware` (cookie-based) | Also `SessionCsrfProtectionMiddleware` |
| Coding standard | PSR-2 | PSR-12 |
| Migrations | `Migrations\AbstractMigration` with `change()` (auto-reversible) | Same |
---
## Naming Conventions
- **Plural**: table names (`platform_packages`), controller classes (`PlatformPackagesController`), table classes (`PlatformPackagesTable`)
- **Singular**: entity classes (`PlatformPackage`)
---
## Files to Explore (Architecture Phase)
When exploring a CakePHP codebase, read these files like a detective:when to use it
Community prompt sourced from the open-source GitHub repo motsmanish/motspilot (MIT). A "Cakephp" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
productivitycommunitydeveloper
source
motsmanish/motspilot · MIT
more in Productivity
Productivity✓ tested
Summarize a doc into decisions & actions
chief of staff who extracts what to DO, not just what was said
Productivity✓ tested
Draft a reply to a hard email
calm, direct communicator who de-escalates without caving
Productivity✓ tested
Turn a brain-dump into a weekly plan
planning coach who protects your focus, not just your calendar