The Bake plugin provides code generation and scaffolding capabilities for CakePHP 2.x applications.
Install the plugin using Composer:
composer require --dev pieceofcake2/bakeOnce installed, you can use the bake commands:
# Bake a model
app/Console/cake bake model User
# Bake a controller
app/Console/cake bake controller Users
# Bake views
app/Console/cake bake view Users
# Bake everything for a model
app/Console/cake bake all User
# Create a new project
app/Console/cake bake project /path/to/new/project
# Create a new plugin
app/Console/cake bake plugin MyPlugin- Model Generation: Create models with associations and validation
- Controller Generation: Create controllers with CRUD actions
- View Generation: Create views for index, view, add, and edit actions
- Test Generation: Create test cases for your code
- Fixture Generation: Create fixtures for testing
- Plugin Generation: Scaffold new plugins
- Project Generation: Create new CakePHP projects
- Custom Templates: Use custom bake templates for code generation
The Bake plugin uses templates for code generation. You can customize these templates by creating your own bake theme.
Create a directory structure in your app:
app/Console/Templates/myTheme/
├── classes/
│ ├── controller.ctp
│ ├── model.ctp
│ └── fixture.ctp
└── views/
├── index.ctp
├── view.ctp
└── form.ctp
Then use your theme:
app/Console/cake bake controller Users --theme myTheme- PHP 8.0+
- CakePHP 2.11+
MIT License