In a previous post I wrote about a shortcut to make the baking a bit faster. In the meantime new shortcuts have been added. In this post I will describe the shortcuts which make the baking of controllers faster.

In the aforementioned article I described that you could use the following statement to bake a controller:

cake bake controller

From this statement the next logical step is to provide a way to define the name of a controller via command line:

cake bake controller Users

This command will generate the following controller:

// app/controllers/users_controller.php
class UsersController extends AppController {
    var $name = 'Users';
    var $scaffold;
}

This may be useful in certain cases, but usually you want to bake the actions, too. To allow that, you have to provide the “scaffold” keyword after the controller name:

cake bake controller Users scaffold

This generates the UsersController with the default implementations for the actions add(), delete(), edit(), index(), and view().

By adding the “admin” keyword, you can also generate the admin functions admin_add(), admin_delete(), admin_edit(), admin_index(), and admin_view():

cake bake controller Users scaffold admin

To generate only the admin functions you have to provide “null” instead of “scaffold”:

cake bake controller Users null admin

I like those shortcuts, they make the baking process a much better experience (I don’t like the question-driven approach). For models there are no such shortcuts available yet, but I am sure they come soon.

Happy baking :)

(thanks to gwoo for his short introduction)

Btw: If you have trouble with setting up the console, have a look at the respective screencasts.