This is exactly what I exposed in my blogpost about Zend\Di
and RAD.
While Zend\Di
is good for development, it is a huge memory and performance bottleneck in production. Even if you cache definitions, it still uses ReflectionClass
and call_user_func_array()
to manipulate your instances. It also has to perform a lot of surrounding operations that are necessary to align injection parameters: just take a look at the number of calls to array_merge
during instantiation of an object via Zend\Di
.
I wrote a module to handle compiling of Zend\Di\Di
instance managers to closures: OcraDiCompiler. It needs a bit of cleanup, but its job is to generate code factory/closures by tracing instantiation logic of Zend\Di
internals. If you want to "revive" it a bit, I'd be glad to help out on that, since it's in my TODO list, but with low priority right now.
Anyway, moving instantiation logic to factories/closures through the ServiceManager
is not as much work as you'd expect, so don't be scared and give it a try: you may like it.