脚本宝典收集整理的这篇文章主要介绍了php – Symfony 2依赖注入Controller构造,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
class PErsonController extends Controller { public function __construct(UtilITyService $Utils) { $this->util = $Utils; } public function indexAction() { ... } }
我必须遵循的道路是什么?
诀窍是将控制器定义为服务,然后使用服务ID而不是类名.
http://symfony.com/doc/current/cookbook/controller/service.html
以上是脚本宝典为你收集整理的php – Symfony 2依赖注入Controller构造全部内容,希望文章能够帮你解决php – Symfony 2依赖注入Controller构造所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。