Search the web
Sign In
New User? Sign Up
zf-tool · ZFTool
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
The "Cannot redeclare class Zend_OpenId_Provider" problem   Message List  
Reply | Forward Message #45 of 73 |

I saw a post or two on zf-general about this issue, and since I had (and managed to solve) it myself, I thought I'd explain what I believe is causing it.

From looking through the code, it appears that Zend_Tool recursively scans through all files and directories in your include_path in order to try and try and find classes which implement either ZendL_Tool_Rpc_Manifest_Interface or ZendL_Tool_Rpc_Provider_Interface. I'm guessing the idea is you can have non-ZF code installed to a directory in your include path that will automatically add functionality to your ZF CLI tool without requiring any setup or configuration by you. E.g. I could go and install a PEAR library which would then magically give me access to some new zf CLI commands.

The issue occurs if you have a copy of zend framework itself within your default include_path, but you've setup Zend_Tool to use a _different_ copy of ZF (using either the ZF_PATH env variable or the zf.php file).  Zend_Tool adds the ZF path you've given it to the include path, and then scans through looking for files that end with '(Tool|Manifest|Provider).php'. The Zend_OpenId_Provider class matches this, so Zend_Tool includes it and then ignores it since it doesn't implement either of the interfaces. But then when it finds the same file in your other copy of zend framework, the script dies with a fatal error since it's including a file which defines a class that already exists.

This might sound like a fairly rare combination of events. The reason I had this particular problem is that I'd checked out a copy of ZF from SVN in order to play with Zend_Tool, but I also already had the Ubuntu zend-framework package installed, and this sits by default in /usr/share/php/libzend-framework-php. I guess this problem will eventually solve itself when Zend_Tool is out of the incubator, since users who've installed ZF to their include_path will have no reason to grab a more recent copy of it in order to use Zend_Tool.

However, while it's a cool idea, I'm not completely convinced that scanning through the include_path and including files based on name alone is a good long term approach. Although quite unlikely, it's theoretically possible that two different libraries might declare a class with the same name in files that matched the regexp pattern, which would cause the same fatal error.

Anyway, for me the solution was simple - I uninstalled the Ubuntu zend framework package, since I don't really need it there. So if anyone else has this issue check the directories in your include path for copies of ZF, or files matching the naming scheme above.

--
Tim Fountain
http://www.tfountain.co.uk/

Thu Sep 11, 2008 8:36 pm

tfountainzf
Offline Offline
Send Email Send Email

Forward
Message #45 of 73 |
Expand Messages Author Sort by Date

I saw a post or two on zf-general about this issue, and since I had (and managed to solve) it myself, I thought I'd explain what I believe is causing it. From...
Tim Fountain
tfountainzf
Offline Send Email
Sep 11, 2008
8:36 pm

Hey Tim, this is a great email, and I am still digesting. I¹ll respond when I have all my thoughts together. Cheers, Ralph ... -- Ralph Schindler Software...
Ralph Schindler
ralphschindler
Offline Send Email
Sep 15, 2008
6:11 am

I ran into a not-entirely unrelated issue that was caused by using a symbolic link to make the Zend and ZendL directories includable. This caused even the zf...
dave_walter
Offline Send Email
Sep 24, 2008
5:30 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help