Zend_Soap_AutoDiscover and eAccelerator
The Zend Framework ships with SOAP functionality and one especially neat class called Zend_Soap_AutoDiscover.
This class uses a comment docblock to auto-generate a WSDL at runtime. I won't go into the details how it works here, but you can check the Zend Framework documentation for an example. When using this class at work, I noticed the WSDL would not always generate correctly. After a lot of digging around, I found the cause: eAccelerator.
eAccelerator is an opcode cache. An opcode cache saves the compiled version of a script so PHP does not have to parse it again. eAccelerator also strips out comments from the script by default. That means once your script gets cached, the Zend_Soap_AutoDiscover class has no way of correctly auto-generating the WSDL.
Fortunately, there are some easy solutions to this problem. The easiest is to configure eAccelerator 0.9.6 to not strip out the comments. When compiling eAccelerator, specify the --with-eaccelerator-doc-comment-inclusion switch in the configure script. Install the new compiled version and make sure to clean out your existing cache directory.
Now if you are running eAccelerator 0.9.5, like me, and are unable to upgrade there is still hope. eAccelerator comes with some ini settings that allow us to not cache scripts. Using the eaccelerator.filter setting, we can tell eAccelerator to ignore scripts by filename. You can set it in your php.ini file or just specify it at runtime:
ini_set('eaccelerator.filter', '!foo/Bar.php !baz.php');
With comments preseved, the Zend_Soap_AutoDiscover class will be able to properly generate the WSDL.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=a0294b42-5e52-4c18-a54b-c96c3d9d7afa)
March 22nd, 2010 - 05:56
OMG. That was the lifesaver
Everything worked on my localhost, but on litespeed – not.
Support told that:
a) I can’t turn off eA for one file
b) I can’t disable removing comments
c) I can switch to PHp5.3 where eA isnt turned ON …
May 5th, 2010 - 23:55
Hello,
Thanks for this tips.
Unfortunately i’m running under eAccelerator 0.9.5, and cannot deploy another one.
i’m trying to declare to not cache some script, but it failling too.
I’m using * char to declare several files and folder to not cache.
Do you know if i need to filter every files involved in my Soap (i mean controller, class, sub class?).
Thanks in advance for your help,
Nauw
May 6th, 2010 - 07:17
The filter syntax is really buggy. I have been reading a lot about the problems people were having. Particularly, filtering a directory with a wildcard was not working, nor was filtering multiple directories at once.
I have settled on the following syntax:
ini_set(‘eaccelerator.filter’,
‘!*SomeSoapClass.php !*AnotherSoapClass.php’);
This is slightly different from my original syntax in that it adds a wildcard to the front of the class name. This fixes some weird issues with how the filter looks for the files to not filter. The problem with this method is that I have to maintain this list as I add more soap classes, but it is the best I have found.
To be clear: only the soap class that is being reflected on needs to be filtered. I don’t even filter my abstract soap class.
Twitter: hermanradtke