作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经使用 composer 安装了 zend 工具
$ composer require zendframework/zftool:dev-master
PHP Deprecated: You are retrieving the service locator from within the class ZFTool\Controller\ModuleController. Please be aware that ServiceLocatorAwareInterface is deprecated and will be removed in version 3.0, along with the ServiceLocatorAwareInitializer. ...
最佳答案
有几个解决方案:
E_USER_DEPRECATED
报告。这"zendframework/zend-mvc:~2.6.0"
将固定getServiceLocator()
.这是推荐的路径。的方式getServiceLocator()
提取的构造函数中的依赖项。 .$db = $this->getServiceLocator()->get('Db\ApplicationAdapter');
$db
属性(property)给你的类(class)。 $db = $this->db
(或只使用该属性!)use Zend\Db\Adapter\AdapterInterface;
use Zend\Mvc\Controller\AbstractActionController;
class YourController extends AbstractActionController
{
private $db;
public function __construct(AdapterInterface $db)
{
$this->db = $db;
}
public function someAction()
{
$results = $this->db->query(/* ... */);
/* ... */
}
}
class YourControllerFactory
{
public function __invoke($container)
{
return new YourController($this->get('Db\ApplicationAdapter'));
}
}
return [
'controllers' => [
'factories' => [
YourController::class => YourControllerFactory::class,
/* ... */
],
/* ... */
],
/* ... */
];
];
关于zend-framework - PHP 已弃用 : You are retrieving the service locator from within the class ZFTool\Controller\ModuleController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35933113/
我是一名优秀的程序员,十分优秀!