views:

81

answers:

3

When I use the zend CLI to create a form, like this, a form gets generated and gets added to the forms folder.

zf create form MyForm

I have a custom class that I'd like to create a custom command for it in the same way and would like to look at the zf create form command for guidance. I suspected it to be in Zend_Framework/bin where there's a shell, php, bat files, but I couldn't find any code there related to the form class creation, maybe i missed?

Anyway, is there a better to accomplish the same thing? like an Zend API that lets me create some of these commands myself? If not my only option would be to see how something like zf create form was created.

+5  A: 

When you run zf, it invokes zf.php in the framework's bin folder. That in turn creates an instance of Zend_Tool_Framework_Client_Console, which jumps through some non-obvious hoops to load up all of the available actions and parse your command. Part of this process involves looking in the /Zend/Tool/Project/Provider/ directory, which houses the classes responsible for providing many of the project-oriented actions (like creating forms).

I haven't ever tried this myself, but there is (apparently somewhat outdated) documentation on creating your own providers, so hopefully following that will get you pointed in the right direction.

Tim Stone
+4  A: 

The ZendCast Integrating Zend_Tool Into Your Application is an excellent introduction to the whole business of creating Zend_Tool providers.

David Weinraub
+4  A: 

You need to create a provider. Look at this nice tutorial : http://weierophinney.net/matthew/archives/242-Creating-Zend_Tool-Providers.html

Maxence