Baking a bit faster with the bake script

Published on May 31, 2007 and tagged with bake  cakephp

With the new console infrastructure in CakePHP 1.2 the way bake is used changed a bit. You now call it with:

cake bake

When using this command you will get this dialog:

[M]odel
[V]iew
[C]ontroller
What would you like to Bake? (M/V/C)

If you know what to bake, this dialog is rather bothering. Fortunately, it is now possible to skip this dialog by providing the type of what you want to bake directly on the command line:

cake bake controller  // for baking a controller
cake bake model  // for baking a model
cake bake view  // for baking views

Even with this shortcut there are still many questions you have to answer during the baking process…

11 comments baked

  • Tom May 31, 2007 at 17:28

    nice but….i guess the direct way is the longer one ;)

  • Brandon May 31, 2007 at 17:53

    You can extend the bake functionality by including var $tasks = array(’Controller’, ‘Model’); in your Task and then call $this->Model->__bake(..); and $this->Controller->__bake(..) within your task.

    I did this to make a neat little “scaffold” task that assumes associations with the model and automatically bakes both Model and Controller (plus has support for plugins1).

    cake scaffold Articles plugin=admin

    :)

  • spark May 31, 2007 at 20:41

    hya,

    a solution to this would be the script reading a queue of answers, since they are almost the same… and only ask something in case of error..
    something like:
    cake bake (controller|1|y|n|n|n|y)
    cake bake (controller|2|y|n|n|n|y)
    cake bake (controller|3|y|n|n|n|y)

    Another solution would a command to generate Models, for instance, to ALL tables , following the same answers.

    But always remember the time saver it already is :)

  • Samuel DeVore May 31, 2007 at 20:55

    I just wish I could just continue with the next model/controller/view after I finish so i don’t have to make my lazy old self restart every time… and that it remembered what I had already done…

  • gwoo June 01, 2007 at 00:26

    There are some good ideas here. It would be nice to have some of them submitted as enhancements. The plan is to extend the tasks to do something similar to what Brandon is proposing. Also, I guess I need to change the bake methods in each of the tasks to be public.

  • cakebaker June 01, 2007 at 19:07

    @all: Thanks for your comments!

    @spark: Yes, I agree that it would be cool to have the possibility to specify all options as command line parameters. But I think it should look different than your proposal ;-)

    @Samuel DeVore: Yes, that are some good points.

  • cakebaker » Faster baking of controllers with the bake shell script June 06, 2007 at 11:15

    [...] a previous post I wrote about a shortcut to make the baking a bit faster. In the meantime new shortcuts have been [...]

  • CakePHP 1.2: The Romance Continues … « Ahsan’s Laboratory August 31, 2007 at 14:24

    [...] Baking a bit faster with the bake script by [...]

  • Lo nuevo en CakePHP 1.2 y las diferencias con CakePHP 1.1 October 15, 2007 at 13:13

    [...] Baking más rápido con el script bake por Cakebaker [...]

  • Xander June 02, 2008 at 08:36

    Another solution would be to create self-running batch file like
    bake_model.bat
    containing

    cake bake model
    pause
    bake_model.bat

    But the questions will still be in the air…

  • cakebaker June 02, 2008 at 17:22

    @Xander: In the meantime there is a faster way to bake models, see Faster baking with bake.

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License