astina / injection-bundle
此包已被废弃且不再维护。未建议替代包。
允许将服务和容器参数注入到控制器中。
0.2.0
2013-05-11 09:51 UTC
Requires
- php: >=5.3.0
- symfony/symfony: >=2.1
This package is not auto-updated.
Last update: 2022-06-20 03:21:09 UTC
README
允许将服务和容器参数注入到控制器中。
安装
步骤 1: 添加到 composer.json
"require" : {
// ...
"astina/injection-bundle":"dev-master",
}
步骤 2: 启用该包
在内核中启用该包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Astina\Bundle\InjectionBundle\AstinaInjectionBundle(), ); }
##使用
use Astina\Bundle\InjectionBundle\Annotation as Inject; class DefaultController { /** * @Inject\Service("session") * @var SessionInterface */ private $session; /** * @Inject\Parameter("acme_foo") */ private $foo; /** * @Route("/foo", name="foo") * @Template */ public function indexAction() { $foo = $this->session->get($this->foo); return array( 'foo' => $foo, ); } }