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
- 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.