pieceofcake2 / bake
Bake plugin for CakePHP 2.x - Code generation tool
Installs: 65
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: ^8.0
- composer/installers: *
- pieceofcake2/cakephp: ^2.10
Requires (Dev)
- cakephp/cakephp-codesniffer: ^5.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.6
- pieceofcake2/app: ^2.1
- pieceofcake2/phpstan-cakephp2: ^0.2.1
README
The Bake plugin provides code generation and scaffolding capabilities for CakePHP 2.x applications.
Installation
Using Composer
Install the plugin using Composer:
composer require --dev pieceofcake2/bake
Usage
Once 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
Features
- 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
Bake Templates
The Bake plugin uses templates for code generation. You can customize these templates by creating your own bake theme.
Custom Bake Themes
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
Requirements
- PHP 8.0+
- CakePHP 2.10.24+
License
MIT License