Cheatography
https://cheatography.com
CakePHP 3 bake cheetsheet
This is a draft cheat sheet. It is a work in progress and is not finished yet.
CakePHP Console Cheat Sheet
Details extracted from CakePHP 3.2.x command prompt.
Installation
composer require --dev cakephp/bake:~1.0
|
PhpStorm comes with composer built in. To install CakePHP via PhpStorm, use the FileNewComposer Project. Then filter for CakePHP and select the cakephp\app composer project.
CakePHP Console
Run the CakePHP console from project root |
bin/cake (use bin\cake for Windows)
|
Possible "shells" |
bake , migrations , i18n , orm_cache , plugin , routes , server , behavior_time , console , orm
|
Run Cake Server (usually on localhost port 8765) |
bin/cake server
|
Run migrations shell (with help) |
bin/cake migrations -h
|
Run bake with plugin prefix |
bin/cake bake.bake -h
|
PHP CLI must be installed and in the path.
Bake Shell Common Options
help |
--help or -h
|
Verbose output |
--verbose or -v
|
Quiet output |
--quiet or -q
|
Plugin to bake into |
--plugin or -p
|
Force overwrite of existing files |
--force or -f
|
Datasource connection to get data from (default: default) |
--connection or -c
|
Theme to use when baking |
--theme or -t
|
Do not bake a test skeleton |
--no-test
|
Do not bake generic CRUD action methods |
--no-actions
|
These options are common to most of the cake shell commands.
Server Shell
Run server shell with (defaults) |
bin/cake server
|
Run server shell and get help |
bin/cake server --help
|
Run server shell on port 9999 |
bin/cake server --port 9999
|
Run server shell using IP of 10.0.0.2 |
bin/cake server --host 10.0.0.2
|
Run server shell with document root dummy/app/root |
bin/cake server --document_root dummy/app/root
|
Run server shell with verbose output |
bin/cake server --verbose
|
example |
bin/cake -H 10.0.0.2 -p 9999 -d dummy/app/root -v
|
Bake Shell: Model
Run bake model shell and list all tables |
bin/cake bake model
|
Bake model class for Friends table |
bin/cake bake model Friends
|
Run bake model shell and get help |
bin/cake bake model --help
|
Generalised use: |
bin/cake bake model [subcommand] [options] [<ModelName>]
|
Options |
other than the default ones |
Table name if "non-conventional" table naming used |
--table <TableName>
|
Disable generation of Entity class |
--no-entity
|
Disable generation of Table class |
--no-table
|
Disable generation of validation rules |
--no-validation
|
Disable generation of a rules checker |
--no-rules
|
Disable generatin of associations |
--no-associations
|
Disable generation of fields |
--no-fields
|
Comma separated list of fields to make accessible |
--fields <fieldname>[,<fieldname>...]
|
Comma separated list of hidden fields |
--hidden <fieldname>[,<fieldname>...]
|
Set the primary key field or fields (comma separated) |
--primary-key <key-field>[,<key-field>...]
|
Display field if you would like to select one |
--display-field <field-name>
|
|
|
Cake Routes Shell
List of all Routes |
bin/cake routes
|
URL Parsing Testing |
bin/cake routes check route-and-options
|
example |
bin/bake routes check /bookmarks/edit/1
|
URL Generation Testing |
bin/cake routes generate controller:controllername action:action other options
|
example |
bin/cake routes generate controller:Bookmarks action:edit 1
|
example with string parameters |
bin/cake routes check "/bookmarks/?page=1&sort=title&direction=desc"
|
Bake Shell: Controller
Bake a controller skeleton |
cake bake controller [subcommand] [options] [<name>]
|
Bake the My controller with CRUD actions |
bin/cake bake controller MyController
|
Bake all controllers with CRUD methods Beware: This may overwrite existing controllers |
cake bake controller all
|
Options |
Plugin to bake into |
--plugin or -p
|
Force overwrite of existing files |
--force or -f
|
Datasource connection to get data from (default: default) |
--connection or -c
|
Theme to use when baking |
--theme or -t
|
Components to use (comma separated) |
--components
|
Helpers to use (comma separated) |
--helpers
|
Namespace/routing prefix to use |
--prefix
|
Do not bake a test skeleton |
--no-test
|
Do not bake generic CRUD action methods |
--no-actions
|
<name> is the name of the controller to bake, and you may use Plugin.name to bake controllers into plugins (optional).
Version Control
Version |
Date |
Notes |
1.0 |
25 April 2016 |
Initial version, there are many more commands to add |
This will be updated each time we add new content to the cheat sheet.
|