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 File New Composer 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) |
|
Run migrations shell (with help) |
|
Run bake with plugin prefix |
|
PHP CLI must be installed and in the path.
Bake Shell Common Options
help |
|
Verbose output |
|
Quiet output |
|
Plugin to bake into |
|
Force overwrite of existing files |
|
Datasource connection to get data from (default: default) |
|
Theme to use when baking |
|
Do not bake a test skeleton |
|
Do not bake generic CRUD action methods |
|
These options are common to most of the cake shell commands.
Server Shell
Run server shell with (defaults) |
|
Run server shell and get 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 |
|
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 |
|
Disable generation of Entity class |
|
Disable generation of Table class |
|
Disable generation of validation rules |
|
Disable generation of a rules checker |
|
Disable generatin of associations |
|
Disable generation of 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 |
|
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 |
|
Options |
Plugin to bake into |
|
Force overwrite of existing files |
|
Datasource connection to get data from (default: default) |
|
Theme to use when baking |
|
Components to use (comma separated) |
|
Helpers to use (comma separated) |
|
Namespace/routing prefix to use |
|
Do not bake a test skeleton |
|
Do not bake generic CRUD action methods |
|
<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.
|