API shell script

Published on May 26, 2007 and tagged with cakephp  shell

Some days ago a new shell script has been added to the core of CakePHP: the API shell. It can be used to display the (public) method signatures of core classes via command line.

The usage of the script is simple (even though I have to admit I understood it only after Mariano Iglesias‘ explanations *g*):

cake api [<path>] <classname>

<path> is optional, but if it is used it has to be one of the following values: “behavior”, “cache”, “controller”, “component”, “helper”, “model”, or “view”. So if you want to show the method signatures of the FormHelper, you would use this command:

cake api helper FormHelper

If no <path> is specified, the script looks in the cake/libs folder for the specified class.

Personally, I think it won’t be very useful for me, because I can request the more detailed online API documentation of a class with a simple url:


http://api.cakephp.org/1.2/class_<underscored_class_name>.html

Btw: On the @TheKeyboard blog the grumpy guy (aka Chris Hartjes) has published a short screencast to introduce another core shell script: the console.

7 comments baked

  • Nate May 26, 2007 at 18:24

    The usefulness comes in the fact that I can find the method I want before you’re finished typing up that URL ;-)

  • spark May 26, 2007 at 21:42

    gosh!
    i was fighting with this tool last night, and went back to the 1.1.x scripts, hoping someone post a little introduction.
    dreams come true ;)

    thanks!

  • cakebaker May 29, 2007 at 18:24

    @Nate: *g*

    @spark: I am glad this article came at the right time for you :)

  • gwoo May 30, 2007 at 17:34

    Ever been on an airplane? I have been flying around a lot and even though I know the API like the back of my hand, I still find the need to verify that I have the correct params.

    BTW, saying the online api gives you more info is a bit premature. Remember you are reporting on code that is in an alpha release and therefore not feature complete. Eventually, the API shell will provide the almost as much information as the online version.

    So, before passing judgement on what is going into the core, think about the fact that the code is still in development.

  • cakebaker May 31, 2007 at 18:55

    @gwoo: If I work offline I simply look at the source.

    Well, I described the current state of the script, and currently the online api provides more info than the script.

  • Joel Moss June 01, 2007 at 04:15

    It would be more useful if you could bring up a method’s comments aswell, perhaps by specifying the method after the class. Then that would negate the need of having to check the API docs or the source – almost!

    Other than that, I like it.

  • gwoo June 01, 2007 at 18:20

    thats the plan

Bake a comment




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

© daniel hofstetter. Licensed under a Creative Commons License