PHP: Zend_Application and not working ressources

If you use PHP and Zend Framwork, you may use Zend_Application, a marvelous componant that appeared in the 1.8 version of the framework.

I just did some tests with it, and more precisely with ressources like translate and db. I had problem with the db ressource: no Zend_Adapter was initialised and thus, no adapter were set as the default one for Zend_DB_Table. It took me an hour of debugging to find the reason because I had just done a copy/paste from the reference guide and my application.ini was identical !

Well, in fact, the problem was the copy / paste: a invisible but bad caracters (160) was inserted between “resources.db.adapter” and “=”. So the option “adapter” was in fact read as something like “adapter ” (notice the space at the end) in PHP. And if you take a look at how ressource’s plugins work, you will see that the option “adapter” is concatenated with “set” to make a call to a method named “setadapter()”. Unfortunately, no error nor exception is thrown if the method does not exists. SO in my case the framework searched for “setadapter ()” which was not existant. So all dbAdapter intialisation was silently ignored…

I hope this could help someone somewhere 😉

Leave a Reply

Your email address will not be published. Required fields are marked *


*