API shell script

Published on 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:


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

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

  • spark

    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 ;)


  • cakebaker

    @Nate: *g*

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

  • gwoo

    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

    @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

    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

    thats the plan

© daniel hofstetter. Licensed under a Creative Commons License