Skip to content

Herman J. Radtke III

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]