1

I am using the ZFTool 2 to create modules and controllers in my projects. When I try to use it to create an action, I encounter an error.

In the documentation it says the following:

Action creation:
  zftool create action <name> <controllerName> <module> [<path>]    create an action in a controller                                                          

  <name>              The name of the action to be created                                                                                                                          
  <controllerName>    The name of the controller in which the action should be created                                                                                              
  <module>            The module containing the controller                                                                                                                          
  <path>              The root path of a ZF2 application where to create the action          

So I entered the following into Terminal:

zftool create action test Index Mymodule my-project-root

I get the following (not that helpful) error message back:

Reason for failure: Invalid arguments or no arguments provided

I also tried it like this, with the same result:

zftool create action testAction IndexController Mymodule my-project-root

Am I doing something wrong here? Why is my action not created? What arguments are invalid?

EDIT
As suggested in the comments I also tried to create the action after changing into the project root to make sure the path is not the problem. I got the following error message:

Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZFTool) could not be initialized.' in /Applications/AMPPS/www/myProject/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:189

Sven
  • 12,997
  • 27
  • 90
  • 148
  • have you tried to create the action inside the application directory ? just to know if the problem is in the path. – blackbishop Aug 10 '14 at 18:24
  • @blackbishop I just tried that, result is the following error message: `Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZFTool) could not be initialized.' in /Applications/AMPPS/www/myProject/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php:189`. – Sven Aug 10 '14 at 20:14
  • sven, i just updated my answer. It should work now. – edigu Aug 10 '14 at 20:40

1 Answers1

1

Probably the last argument my-project-root is wrong. It should represent a correct physical root path of a ZF2 application.

Try this:

zftool create action foobar   Index        Application /path/to/your/project
                     [action] [Controller] [Module]    [Your project root]

EDIT: After your updates, i realized that problem may related with your ZFTool installation. (Assuming that you're trying to use zftool as an external command). Try to attach it as module into your project:

$ cd /path/to/your/projectroot
$ php composer.phar selfupdate
$ php composer.phar require --dev zendframework/zftool:dev-master
$ ./vendor/bin/zf.php create action foobar Index Application

As you can see, there are no need to setting project root explicitly in this approach.

edigu
  • 9,878
  • 5
  • 57
  • 80
  • Thanks for your help! To make sure the path is not a problem, I've now changed into my project root folder before executing the command, but without much luck. I've added the error message I get to my post. – Sven Aug 10 '14 at 20:18
  • Thank you, that worked! I had the ZFTool simply globally installed in my PATH for easy access, I didn't knew I need to add it to the project. – Sven Aug 11 '14 at 07:27