eAccelerator and Doctrine 2

A word of warning: eAccelerator does not play well with Doctrine 2. This came to my attention today after I installed eAccelerator so that I could measure the performance gains (if any). As it turns out, one of eAccelerator’s “features” is to remove Docblocks from PHP scripts – probably to reduce compile times. Suddenly my application was throwing exceptions with the message “Class X is not a valid entity or mapped super class”.

There are ways to configure eAccelerator to ignore Docblocks when “optimising” your code (see this bug report), but I think it is absurd that eAccelerator makes it so difficult to use Docblocks — beberlei from the Doctrine team summed the issue up pretty well:

“I think it is a very bad style to remove the docblocks from the opcode. The performance gain is probably unmeasurable, however it will severly break applications that rely on the Docblocks (a language feature!! removed). Currently opensource projects using Docblocks are getting more and more:

  • Doctrine 2
  • Zend Framework
  • Symfony 2
  • Flow3
  • PHPUnit
  • and many more…

This premature optimization to remove the docblocks should be reverted. Docblocks are a PHP Token for a reason, they are part of the language and should be used that way. Please revise your stand on this otherwise projects must suggest NOT to use¬†eAccelerator¬†by default.”

The bottom line is this: if you are mapping your Doctrine 2 entities using Docblock annotations; you will save yourself a lot of time and stress by not using eAccelerator.

Handy tip: to see if eAccelerator is loaded in your PHP installation, call print_r(get_loaded_extensions()); and see if eAccelerator is in the array. To disable eAccelerator, open your php.ini file and find zend_extension = "/path/to/extensions/php_eaccelerator.dll". Put a semicolon (;) in front of it to comment it out, and restart your web server.

Did you find this post useful?

6 thoughts on “eAccelerator and Doctrine 2

  1. Pingback: (Advertising online|Logo design|Website design|Article writing|Back linking|SEO services|Social media|Marketing|Facebook fans|Twitter fans|Gig}

  2. Pingback: Starting with Symfony2 – Troubleshooting number #1 « Shaked Klein Orbach

  3. Pingback: Doctrine 2 / PHP – getDocComment() always returns false – AnnotationReader / DocParser fails | PHP Developer Resource

  4. Pingback: Anderes Verhalten meines Webservice nach Umstellung auf Produktiv-Server - Zend Framework Forum

  5. Solution:

    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.

    It’s not from me, i found here:
    http://www.hermanradtke.com/blog/zend_soap_autodiscover-and-eaccelerator/

  6. Pingback: PHP optimizers and The Bug Genie – revisited « The Bug Genie team blog

Leave a Reply