Zend_Tool: Fatal error: Cannot redeclare class Zend_Loader

余生长醉 提交于 2019-12-11 01:21:30

问题


I am able to create new projects with...

zf create project ProjectName

...but this creates a project without copying the Zend Framework library. So I copy ZF into my project library and try to create a controller...

zf create controller auth

...and I get this message:

Fatal error: Cannot redeclare class Zend_Loader in /home/andrew/Projects/test/library/Zend/Loader.php on line 31

Call Stack:
    0.0010     110164   1. {main}() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/bin/zf.php:0
    0.0010     110284   2. zf_main() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/bin/zf.php:23
    0.0116     685448   3. zf_run() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/bin/zf.php:36
    0.0116     685568   4. Zend_Tool_Framework_Client_Console::main() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/bin/zf.php:214
    0.0117     686084   5. Zend_Tool_Framework_Client_Abstract->dispatch() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Framework/Client/Console.php:96
    0.4133    4366424   6. Zend_Tool_Framework_Client_Abstract->_handleDispatch() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Framework/Client/Abstract.php:227
    0.4134    4366424   7. call_user_func_array() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Framework/Client/Abstract.php:308
    0.4134    4366424   8. Zend_Tool_Project_Provider_Controller->create() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Framework/Client/Abstract.php:0
    0.4134    4366424   9. Zend_Tool_Project_Provider_Abstract->_loadProfile() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Provider/Controller.php:135
    0.4135    4366652  10. Zend_Tool_Project_Profile->loadFromFile() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Provider/Abstract.php:136
    0.4791    4368888  11. Zend_Tool_Project_Profile_FileParser_Xml->unserialize() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Profile.php:181
    0.4850    4424620  12. Zend_Tool_Project_Profile_FileParser_Xml->_lazyLoadContexts() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Profile/FileParser/Xml.php:110
    0.4886    4434348  13. Zend_Tool_Project_Profile_Resource->initializeContext() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Profile/FileParser/Xml.php:217
    0.4887    4434944  14. Zend_Tool_Project_Context_Zf_BootstrapFile->init() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Profile/Resource.php:226
    0.4899    4437540  15. Zend_Application->__construct() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Tool/Project/Context/Zf/BootstrapFile.php:81
    0.5137    4548240  16. Zend_Application->setOptions() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Application.php:92
    0.5179    4696108  17. Zend_Application->setBootstrap() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Application.php:176
    0.5219    4896172  18. Zend_Application_Bootstrap_Bootstrap->__construct() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Application.php:317
    0.5223    4902596  19. Zend_Application_Bootstrap_BootstrapAbstract->hasPluginResource() /home/andrew/Projects/test/library/Zend/Application/Bootstrap/Bootstrap.php:49
    0.5223    4902596  20. Zend_Application_Bootstrap_BootstrapAbstract->getPluginResource() /home/andrew/Projects/test/library/Zend/Application/Bootstrap/BootstrapAbstract.php:314
    0.5223    4902596  21. Zend_Application_Bootstrap_BootstrapAbstract->_loadPluginResource() /home/andrew/Projects/test/library/Zend/Application/Bootstrap/BootstrapAbstract.php:348
    0.5223    4902676  22. Zend_Application_Bootstrap_BootstrapAbstract->getPluginLoader() /home/andrew/Projects/test/library/Zend/Application/Bootstrap/BootstrapAbstract.php:701
    0.5223    4902760  23. Zend_Loader_Autoloader::autoload() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Loader/Autoloader.php:0
    0.5224    4902760  24. call_user_func() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Loader/Autoloader.php:130
    0.5224    4902760  25. Zend_Loader_Autoloader->_autoload() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Loader/Autoloader.php:0
    0.5224    4902896  26. call_user_func() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Loader/Autoloader.php:474
    0.5224    4902956  27. Zend_Loader::loadClass() /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Loader/Autoloader.php:0
    0.5241    5000704  28. include('/home/andrew/Projects/test/library/Zend/Loader/PluginLoader.php') /opt/ZendFramework/ZendFramework-1.9.3PL1-minimal/library/Zend/Loader.php:83
    0.5251    5057592  29. require_once('/home/andrew/Projects/test/library/Zend/Loader.php') /home/andrew/Projects/test/library/Zend/Loader/PluginLoader.php:27

What is wrong with my setup? How can I get Zend_Tool to work like it's supposed to work?


回答1:


In your config file (application.ini) comment out this line with a semicolon:

;includePaths.library = APPLICATION_PATH "/../library"

This will prevent Zend_Loader from being included twice.



来源:https://stackoverflow.com/questions/1574454/zend-tool-fatal-error-cannot-redeclare-class-zend-loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!