symplify / controller-autowire
This package is abandoned and no longer maintained.
The author suggests using the symfony/dependency-injection package instead.
There is no license information available for the latest version (v2.0.0-RC2) of this package.
Adds support to autowire controller constructor without pain.
v2.0.0-RC2
2017-04-27 14:57 UTC
Requires
- php: ^7.1
- nette/robot-loader: ^3.0
- symfony/config: ^3.2
- symfony/dependency-injection: ^3.2
- symfony/http-kernel: ^3.2
- symfony/security: ^3.2
- symfony/serializer: ^3.2
- symfony/yaml: ^3.2
Requires (Dev)
- doctrine/annotations: ^1.4
- nette/finder: ^2.4
- nette/utils: ^2.4
- phpunit/phpunit: ^6.0
- symfony/framework-bundle: ^3.2
- dev-master
- v2.0.0-RC2
- v2.0.0-RC1
- v1.4.10
- v1.4.9
- v1.4.4
- v1.4.1
- v1.4.0
- v1.3.3
- v1.3.1
- v1.3.0
- v1.2.21
- v1.2.20
- v1.2.19
- v1.2.18
- v1.2.17
- v1.2.16
- v1.2.15
- v1.2.14
- v1.2.13
- v1.2.12
- v1.2.11
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.0.0
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.2
- v0.1.1
- v0.1.0
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-main
This package is auto-updated.
Last update: 2022-01-17 10:33:15 UTC
README
This bundle does only 2 things. But does them well:
- 1. registers controllers as services and
- 2. enables constructor autowiring for them
Still wondering why use controller as services? Check this and this article.
Install
composer require symplify/controller-autowire
Add bundle to AppKernel.php
:
class AppKernel extends Kernel { public function registerBundles() { $bundles = [ new Symplify\ControllerAutowire\SymplifyControllerAutowireBundle(), // ... ]; } }
Usage
class SomeController { private $someClass; public function __construct(SomeClass $someClass) { $this->someClass = $someClass; } }
Used to FrameworkBundle's controller? Use helpers traits!
Inspired by pull requests to Symfony and setter injection that are currently on-hold, here are the traits you can use right now:
use Symplify\ControllerAutowire\Controller\Routing\ControllerAwareTrait; final class SomeController { use ControllerAwareTrait; public function someAction() { $productRepository = $this->getDoctrine()->getRepository(Product::class); // ... return $this->redirectToRoute('my_route'); } }
Do you prefer only traits you use?
use Symplify\ControllerAutowire\Controller\Routing\ControllerRoutingTrait; final class SomeController { use ControllerRoutingTrait; public function someAction() { return $this->redirectToRoute('my_route'); } }
Just type Controller*Trait
in your IDE to autocomplete any of these traits.
That's all :)
Contributing
Send issue or pull-request to main repository.