ZF2: how do I get ServiceManager instance from inside the custom class
问题 I'm having trouble figuring out how to get ServiceManager instance from inside the custom class. Inside the controller it's easy: $this->getServiceLocator()->get('My\CustomLogger')->log(5, 'my message'); Now, I created a few independent classes and I need to retrieve Zend\Log instance inside that class. In zend framework v.1 I did it through static call: Zend_Registry::get('myCustomLogger'); How can I retrieve the My\CustomLogger in ZF2? 回答1: Make your custom class implement the