Docblock, Oh Docblock, wherefore art thou Docblock (hint: Zend Optimizer Plus lost them)

Published by

Matt Cockayne

Matt is both a PHP Developer and Scout Leader. Having tried his hand a few different careers he finds that he is happiest working with code as the Technical Lead at Magma Digital. As a framework contributor and serial tinkerer Matt has spent a long time working on being the best PHP Developer he can be. As a Scout Leader he spends a lot of his time devoted to teaching valuable life skills to kids aged 7-18. He is a firm believer that being a Good Scout and Great Developer go hand in hand.

4 thoughts on “Docblock, Oh Docblock, wherefore art thou Docblock (hint: Zend Optimizer Plus lost them)”

  1. I’ve just seen this post and as an heavy annotations user (Doctrine, ZF2 Form Annotations and┬ámy own TjoAnnotationRouter) I find it pretty concerning that they are talking about including optimizer+ in 5.5 without this feature being available. I’m all for them including it but I think this should be addressed.

    On the flip side though, through my own work I discovered that annotation parsing (certainly through the facilities provided by ZF2) can be quite a performance hit so I figure they should be cached/”compiled” to PHP code on your production server anyway. So, so long as you can disable Optimizer+ on the dev server then it may not be a problem – but still annoying.

    1. From my understanding you will be able to disable it and implement a different cache if you choose to.

      Your right in the performance hit which is why tools like Doctrine try and cache the metadata generated into something like APC/Memcache. But at some point your docblocks will need to be read in order to populate that cache.

      On the whole its not the end of the world and its given me the chance to investigate alternatives ways to handle Annotation data and ways to improve performance.

      I definitely want to see it integrated but think that it may require more work before its an acceptable solution for me. What does concern is the possibility that it may introduce other unanticipated side effects. Something else to note is that the problems I’ve identified here are not present in Zend Server! Does that mean that they are not using Optimizer? or are they only open-sourcing an old version and keeping the most current version for themselves?

  2. It turns out that OptimizerPlus suffers from the same flaws that eAccellerator does and strips Docblocks when caching the bytecode.

    Uhh, no. The default is to not touch comments:

    php -i | grep comments
    zend_optimizerplus.load_comments => 1 => 1
    zend_optimizerplus.save_comments => 1 => 1

    Which means you’ve specifically told ZO+ to strip comments. And you’re getting what you asked for.

    1. Hi Dominic… Fantastic thank you for pointing this out. I will mention that I installed Optimiser using the defaults provided by the source which was at the time of my compiling to strip comments. That said I’ve now updated my config and its working. Once again thanks for pointing this out

Leave a Reply