A first glimpse at two core bake tasks

Published on and tagged with bake  cakephp  task

Felix already wrote about the new bake2.php script. This script is rather simple, it simply executes tasks, i.e. classes with a certain interface. At the moment, there exist two such tasks in the branch of CakePHP 1.2: AppTask and DbconfigTask. Let’s have a look at them, even though they are not finished yet.

The AppTask creates the application skeleton. The usage is:

php bake2.php app alias /path_to_app_dir

It does almost the same as:

php bake.php -project /path_to_app_dir

The differences are:

  • bake2 doesn’t ask you any questions
  • you can define an application alias

The idea of the application alias is to make it easier to work with multiple applications. So you can use just the alias to refer to a specific application. The alias/application mapping is stored in apps.ini, in the root folder of your cake installation.

After the AppTask you will usually execute the DbconfigTask to create the database configuration. This task allows a lot of parameters, but most of them are optional. Here is its usage:

php bake2.php dbconfig alias database username [password] [-c=config name] [-d=database driver] 
                                               [-persistent] [-h=host[:port]] [-p=prefix]

That’s it. Feedback and bug reports are welcome :)

5 comments baked

  • Dieter@be

    The AppTask will be very handy i think, but i’m not so sure about the DbconfigTask.
    If all it does is generate/edit an app/config/database.php file for you, it offers just a slight advantage over manually editing the file. It will be a little faster if done right, but personally i would still open the file to check if all is right, and besides, if you edit manually, you can see all the needed parameters (there are defaults that you can edit) so you can be sure you didn’t forget any.

    Maybe it would be handy if you could call it like this:
    php bake2.php dbconfig alias [-a=ask] or even make this value the default is no arguments (database,username) are given, so it would prompt for every parameter, then you can be sure you didn’t forget any :)


  • cakebaker

    @Dieter@be: Thanks for your comment.

    The dbconfigTask uses default values for parameters you don’t specify. And it is thought for advanced users who know what they do and who don’t need the assistance provided by the bake.php script.

  • Dieter@be

    Okay, maybe you could supply a little synopsis if called like this then?:
    php bake2.php dbconfig [–help]

    That way you loose the overhead of having a whole question-response loop, while still users can be sure they didn’t forget anything (if they check the synopsis first)

    because seriously, even “advanced users who know what they do” will sometimes forget to pass a parameter :-)


  • cakebaker

    @Dieter@be: This feature is already integrated :) You can call:
    php bake2.php dbconfig help

    But I think I will also add “–help”, as this is very common on unix-based systems.

  • Dieter@be

    excellent ;-)

© daniel hofstetter. Licensed under a Creative Commons License