ZF-6755: Zend_Tool_Project_Provider_Controller refuses to create a controller in a module if a controller with the same name exists in default module


I just discovered Zend_Tool and I'm testing it right now.

I'm using modules in an existing project, so I tested this aspect too, and I hit a bug. Here's what I'm doing:

$ zf create project zf-site $ cd zf-site $ zf create module admin

Then, if i do:

$ zf create controller MyCtrlr 1 admin

It works, and successfully creates a MyCtrlr controller in the admin module, with an initial IndexAction method

But if i try:

$ zf create controller index 1 admin

It fails with the error "This project already has a controller named index"

The only index controller that exists is in the default module, so the creation of an index controller in the admin module should be accepted.

I'm new to the code of Zend_Tool, so I don't know what is done on purpose or is temporary, but I guess the error comes from line 141 (as of ZF 1.8.1) in Zend/Tool/Project/Provider/Controller.php :

141 if (self::hasResource($this->_loadedProfile, $name)) {

If I'm not mistaken, a 3rd parameter in hasResource() is accepted, giving the $module, so maybe the line should be:

141 if (self::hasResource($this->_loadedProfile, $name, $module)) {

I just tried with this change, and it seems to work


I too was unable to get zf (zend_tool) to create an IndexController because one by the same name existed in application/controllers.

I made the same edit to line 141 in Controllers.php file adding $module as an argument to be passed to hasResource method and was then able to create the file.

Similarly, when trying to create an action in the controller

zf create action index index 1 module

This would give an error because an indexAction already existed in the default IndexController

edited line#129 in Zend/Tool/Project/Provider/Action.php

From: if (self::hasResource($this->_loadedProfile, $name, $controllerName)) To: if (self::hasResource($this->_loadedProfile, $name, $controllerName, $module))

Seems to work okay after that.

Solved in SVN r16174