The Locator is the interface. The design of Zend Framework 2 is done with "design by contract" which means you rely on interfaces rather than classes. The Manager is a default implementation of the Locator.
All but one component use the Locator. However, the manager provides more features than the interface says. The Zend\Mvc\Application
uses these features and therefore relies on the Manager instead of the Locator.
The decision to use the Locator in the *Aware initializers was made too late for the release, so this is why there is both a ServiceLocatorAwareInterface
and a ServiceManagerAwareInterface
. There was already userland code using the Manager's initializer so it's kept for backwards compatibility. Internally all components use the Locator initialzer. If you have to choose, pick the Locator and leave the Manager as much as possible aside.
Quite some time ago I also blogged about the Locator and the Manager: https://juriansluiman.nl/article/120/using-zend-framework-service-managers-in-your-application
Zend\ServiceManager\ServiceManagerAwareInterface.php
andZend\ServiceManager\ServiceLocatorAwareInterface.php
. If SM is the implementaion of SL, why do we have a separate interface. – Koniology