zendframework/zf2 — pull request #2995 by Ocramius (2012-11-17 02:09:16+00:00)
Title: [WIP] Feature/lazy services

This PR introduces a huge performance tweak for the `ServiceManager`.

It is a service proxy generation logic based on top of the current proxy generation I am using for doctrine/common#168 (not yet merged, and this cannot be merged until doctrine/common 2.4 is out).

Basically, each service configured to be lazy is wrapped in a service proxy before being returned. This delays instantiation.

You can see a complete example of how this works in the results of the PHPPeru hackday I had with @cordoval [in this blogpost](http://www.craftitonline.com/2012/11/lazy-load-services-and-do-not-inject-the-container-into-them/).

My primary aim is to reduce usage of service location (which I personally started considering harmful) in favour of dependency injection.

I've tested it and it works quite fine. Please let me know your thoughts, since this is quite a big shot :)