Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weier O'Phinney:
On Deprecating ServiceLocatorAware
Apr 27, 2016 @ 16:16:51

In this post to his site Matthew Weier O'Phinney talks about a change in the Zend Framework ZendMVC package to deprecate the ServiceLocatorAware interface and some of the unexpected backlash of it.

A month or two ago, we pushed a new release of zend-mvc that provides a number of forwards-compatibility features to help users prepare their applications for the upcoming v3 release.

One of those was, evidently, quite controversial: in v3, zend-servicemanager no longer defines the ServiceLocatorAwareInterface, and this particular release of zend-mvc raises deprecation notices when you attempt to inject a service locator into application services, or pull a service locator within your controllers.

He shares some of the "constructive" feedback they received when they made the change, most importantly asking for a justification for the change. He then goes through their thinking behind the change, some of its original intent and how it allowed for "dependency hiding" in its use. He gets into some detailed code examples for this last point, some of the errors that could happen as a result and other issues (like no type safety and the brittleness of using a service locator).

tagged: deprecation servicelocatoraware interface zendframework zendframework3

Link: https://mwop.net/blog/2016-04-26-on-locators.html


Trending Topics: