Just learning ZF2, and I am a bit confused. I have a general understanding of the ServiceManager, and understand how to add Services, as well as using ServiceManagerAwareInterface to be able to pull Services into a class. However in my searching I have come across a ServiceLocatorAwareInterface.
Can someone tell me the difference between the two and what scenarios I would use each?
ServiceManagerAwareInterfacewas introduced to cover specific needs of MVC component, which required specific implementation of service locator. iirc this limitation was lifted andServiceManagerAwareInterfaceunofficially considered deprecated.As for you, you do not want to depend on specific implementation rather than on contract aka interface. Hence you should prefer
ServiceLocatorAwareInterface.