Issues

ZF-8389: call to undefined member function search() - Zend Tool

Description

when creating a new (modular) project using Zend_Tool, I am presented with an error in terminal. The error occurs when creating an action on a controller within a module

"zf create action testaction indexcontroller 1 defaultmodule" the help states that the action should be create by using the following: zf create action name controller-name[=index] view-included[=1] module

but when executing the command php returns the following error: Fatal error: Call to a member function search() on a non-object in /usr/share/php5/Zend/Tool/Project/Provider/Action.php on line 92

line 92 of the particular file is: "return (($controllerFile->search(array('actionMethod' => array('actionName' => $actionName)))) instanceof Zend_Tool_Project_Profile_Resource);"

steps i followed: zf create project test zf create module default zf create controller index 1 default zf create action testaction index 1 default (error occurs here)

Comments

Possibly linked

I'd really like to see some kind of resolution here.

I really think the tool was a big step forward, but this error makes it unusable with modules.

I had similar problem. My case was in the quickstart application. As I read in another bug report, the issue was related to a lower case letter instead of an upper one.

Using zf.sh create action sign guestbook

gave

Fatal error: Call to a member function search() on a non-object in /usr/share/php/libzend-framework-php/Zend/Tool/Project/Provider/Action.php on line 92

Call Stack: 0.0007 110156 1. {main}() /usr/share/zend-framework/zf.php:0 0.0008 110276 2. zf_main() /usr/share/zend-framework/zf.php:23 0.0078 682860 3. zf_run() /usr/share/zend-framework/zf.php:36 0.0078 683172 4. Zend_Tool_Framework_Client_Console::main() /usr/share/zend-framework/zf.php:214 0.0078 684396 5. Zend_Tool_Framework_Client_Abstract->dispatch() /usr/share/php/libzend-framework-php/Zend/Tool/Framework/Client/Console.php:96 0.4479 4326756 6. Zend_Tool_Framework_Client_Abstract->_handleDispatch() /usr/share/php/libzend-framework-php/Zend/Tool/Framework/Client/Abstract.php:227 0.4480 4328856 7. call_user_func_array() /usr/share/php/libzend-framework-php/Zend/Tool/Framework/Client/Abstract.php:308 0.4480 4329564 8. Zend_Tool_Project_Provider_Action->create() /usr/share/php/libzend-framework-php/Zend/Tool/Framework/Client/Abstract.php:0 0.4727 5073744 9. Zend_Tool_Project_Provider_Action::hasResource() /usr/share/php/libzend-framework-php/Zend/Tool/Project/Provider/Action.php:129


I solved calling 'Guestobook' instead of 'guestbook'


zf.sh create action sign Guestbook

Creating an action named sign inside controller at /home/amaragna/NetBeansProjects/progetto1/application/controllers/GuestbookController.php Updating project profile '/home/amaragna/NetBeansProjects/progetto1/.zfproject.xml' Creating a view script for the sign action method at /home/amaragna/NetBeansProjects/progetto1/application/views/scripts/Guestbook/sign.phtml Updating project profile '/home/amaragna/NetBeansProjects/progetto1/.zfproject.xml'

hope it will help.

Angelo Maragna

I had high hopes for this workaround, but unfortunately it still fails for me.

d:\Server\project73>zf create action login 1 Profile PHP Fatal error: Call to a member function search() on a non-object in D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Project\Provider\Action.php on line 92 PHP Stack trace: PHP 1. {main}() D:\Applications\ZendFrameworkCLI\bin\zf.php:0 PHP 2. zf_main() D:\Applications\ZendFrameworkCLI\bin\zf.php:23 PHP 3. zf_run() D:\Applications\ZendFrameworkCLI\bin\zf.php:36 PHP 4. Zend_Tool_Framework_Client_Console::main() D:\Applications\ZendFrameworkCLI\bin\zf.php:214 PHP 5. Zend_Tool_Framework_Client_Abstract->dispatch() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Console.php:96 PHP 6. Zend_Tool_Framework_Client_Abstract->_handleDispatch() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Abstract.php:227 PHP 7. call_user_func_array() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Abstract.php:308 PHP 8. Zend_Tool_Project_Provider_Action->create() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Abstract.php:0 PHP 9. Zend_Tool_Project_Provider_Action::hasResource() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Project\Provider\Action.php:129

Fatal error: Call to a member function search() on a non-object in D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Project\Provider\Action.php on line 92

Call Stack: 0.0007 380544 1. {main}() D:\Applications\ZendFrameworkCLI\bin\zf.php:0 0.0007 380544 2. zf_main() D:\Applications\ZendFrameworkCLI\bin\zf.php:23 0.0078 999464 3. zf_run() D:\Applications\ZendFrameworkCLI\bin\zf.php:36 0.0078 999584 4. Zend_Tool_Framework_Client_Console::main() D:\Applications\ZendFrameworkCLI\bin\zf.php:214 0.0078 1000336 5. Zend_Tool_Framework_Client_Abstract->dispatch() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Console.php:96 2.6022 4177680 6. Zend_Tool_Framework_Client_Abstract->_handleDispatch() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Abstract.php:227 2.6022 4178464 7. call_user_func_array() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Abstract.php:308 2.6022 4178800 8. Zend_Tool_Project_Provider_Action->create() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Framework\Client\Abstract.php:0 2.6381 5089808 9. Zend_Tool_Project_Provider_Action::hasResource() D:\Applications\ZendFrameworkCLI\library\Zend\Tool\Project\Provider\Action.php:129

The thing with what Angelo posted it that he wasn't using modules. (zf create action login 1 Profile - no module name specified). From what I can gather from reading through the source in the trunk svn, is that the tool is being rewritten (or heavily modified) for a future release. I tried to test the trunk, but my system complained at me. I am going to have another look at some point soon to see if it has been fixed.

For me the naming differences triggers this:


zf create module blog
zf create controller --name=Index --module=Blog // error
zf create controller --name=Index --module=blog

When I execute the commands mentioned in the OP, then no error occurs any more in 1.10.5. Seems to be fixed already and issue could be closed.

zf create project test zf create module default zf create controller index 1 default zf create action testaction index 1 default (no error occurs here)

I was getting a similar error to this issue in my install of 1.10.4.


zf create module default PHP Fatal error: Call to a member function search() on a non-object in /usr/share/php/libzend-framework-php/Zend/Tool/Project/Provider/Module.php on line 70

Fatal error: Call to a member function search() on a non-object in /usr/share/php/libzend-framework-php/Zend/Tool/Project/Provider/Module.php on line 70

Which is also referencing Zend_Tool_Project_Profile_Resource

The problem was caused by my deleting all the modulesDirectory related references in .zfproject.xml.

Perhaps there should be something in place to add missing lines like this? Adding the line


 

resolved this issue for me.

I've tried the following script, and I cannot reproduce, please reopen if there are different instructions to reproduce.


~/tmp/zftoolscratch$ cd test/

~/tmp/zftoolscratch/test$ zf create module default
Creating the following module and artifacts:
/Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/controllers
/Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/models
/Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/views
/Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/views/scripts
/Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/views/helpers
/Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/views/filters
Added a key for the default module to the application.ini file
Updating project profile '/Users/ralphschindler/tmp/zftoolscratch/test/.zfproject.xml'

~/tmp/zftoolscratch/test$ zf create controller index 1 default
Note: The canonical controller name that is used with other providers is "Index"; not "index" as supplied
Creating a controller at /Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/controllers/IndexController.php
Creating an index action method in controller Index
Creating a view script for the index action method at /Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/views/scripts/index/index.phtml
Creating a controller test file at /Users/ralphschindler/tmp/zftoolscratch/test/tests/application/controllers/IndexControllerTest.php
Updating project profile '/Users/ralphschindler/tmp/zftoolscratch/test/.zfproject.xml'

~/tmp/zftoolscratch/test$ zf create action test Index 1 default
Creating an action named test inside controller at /Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/controllers/IndexController.php
Updating project profile '/Users/ralphschindler/tmp/zftoolscratch/test/.zfproject.xml'
Creating a view script for the test action method at /Users/ralphschindler/tmp/zftoolscratch/test/application/modules/default/views/scripts/index/test.phtml
Updating project profile '/Users/ralphschindler/tmp/zftoolscratch/test/.zfproject.xml'

In general though, I'd stay away from creating modules named 'default' unless you are aware of the repercussions in Zend_Controller as 'default' is a reserved Zend_Controller name.

-ralph

Hello all! I was getting a similar error to this issue. I solved it just editing my .zfproject.xml. First I created a new project em tried to create modules. Got no errors. I merged my new .zfproject.xml with my old and found de differences in controllers em views nodes. So I deleted my Application/Controllers folder and now I can run the zf commands sucessfuly. Try to delete Application/Controllers folder if exists.

Jordan