astina / injection-bundle
Lets you inject services and container parameters into controllers.
Installs: 6 043
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 12
Forks: 0
Type:symfony-bundle
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
Lets you inject services and container parameters into controllers.
Installation
Step 1: Add to composer.json
"require" : {
// ...
"astina/injection-bundle":"dev-master",
}
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Astina\Bundle\InjectionBundle\AstinaInjectionBundle(), ); }
##Usage
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, ); } }