zf3 getServiceManager在控制器的构造函数中

时间:2017-04-09 17:08:29

标签: zend-framework3

如何在控制器的构造函数中调用方法getServiceManager?

如果我采取行动方式,那就好了

  public function __construct()
    {

      $this->logger =  $this->getEvent()->getApplication()->getServiceManager()->get("Zend\Log\Logger\Debug");

    }

,但在构造函数getServiceManager中给出错误:

Call to a member function getServiceManager() on null in C:\htdocs\test-zend2\module\Application\src\Controller\IndexController.php on line 32.

0 个答案:

没有答案