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…
nice but….i guess the direct way is the longer one ;)
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
:)
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 :)
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…
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.
@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.
[…] a previous post I wrote about a shortcut to make the baking a bit faster. In the meantime new shortcuts have been […]
[…] Baking a bit faster with the bake script by […]
[…] Baking más rápido con el script bake por Cakebaker […]
Another solution would be to create self-running batch file like
bake_model.bat
containing
But the questions will still be in the air…
@Xander: In the meantime there is a faster way to bake models, see Faster baking with bake.
There’s something missing … because when I try the nice and simple cake bake, I get bash errors.
kiwi april$ cake bake
-bash: cake: command not found
@April: Well, you have to add the cake/console directory to your path. Alternatively, you have to call the script with specifying the path, like $ /path/to/cake/console/cake bake
Hope that helps!