The Bake console is run using the PHP CLI (command line interface). If you have problems running the script, ensure that:
You have the PHP CLI installed and that it has the proper modules enabled (eg: MySQL, intl).
Users also might have issues if the database host is ‘localhost’ and should try ‘127.0.0.1’ instead, as localhost can cause issues with PHP CLI.
Depending on how your computer is configured, you may have to set execute
rights on the cake bash script to call it using bin/cake bake
.
Before running bake you should make sure you have at least one database connection configured.
You can get the list of available bake command by running bin/cake bake --help
(For Windows usage bin\cake bake --help
)
$ bin/cake bake --help
Current Paths:
* app: src/
* root: /path/to/your/app/
* core: /path/to/your/app/vendor/cakephp/cakephp/
Available Commands:
Bake:
- bake all
- bake behavior
- bake cell
- bake command
- bake command_helper
- bake component
- bake controller
- bake controller all
- bake enum
- bake fixture
- bake fixture all
- bake form
- bake helper
- bake mailer
- bake middleware
- bake model
- bake model all
- bake plugin
- bake template
- bake template all
- bake test
To run a command, type `cake command_name [args|options]`
To get help on a specific command, type `cake command_name --help`
Models are generically baked from the existing DB tables.
The conventions here apply, so it will detect relations based on thing_id
foreign keys to things
tables with their id
primary keys.
For non-conventional relations, you can use references in the constraints / foreign key definitions for Bake to detect the relations, e.g.:
->addForeignKey('billing_country_id', 'countries') // defaults to `id`
->addForeignKey('shipping_country_id', 'countries', 'cid')
The theme option is common to all bake commands, and allows changing the bake template files used when baking. To create your own templates, see the bake theme creation documentation.