While the previous article opens up many refactoring strategies, it is still important to work out the details. This time, I will cover sharing application settings (including PHP options which ZF1 apps tend to set in the runtime) and sharing error handling.
In the previous part, we got Zend Expressive working on top of legacy Zend Framework 1 application. This was only the first step towards deeper integration. In this post, I will show how to bring these apps closer by introducing shared Service Container. It will open up new strategies of refactoring.
Writing factories for
zend-servicemanager can be a tedious, repetitive task. Most of factories
I write follow the same pattern: pull some dependencies from the container, instantiate new
object and return it. How can you avoid the repetition?
There's an important question often rising when working on Zend Framework 2 module:
should I test service factories? After all, they are usually trivial, they create some object
and inject it with dependencies from
ServiceManager. Having one test per factory seems to be an
Better to go one step back, and ask yourself a question: what exactly do you want to test?