This bundle does only 2 things. But does them well:
- 1. registers controllers as services and
- 2. enables contstructor autowiring for them
Still wondering why use controller as services? Check this and this article.
Note: If you look for controller method autowiring, see ActionAutowire bundle.
composer require symplify/controller-autowire
Add bundle to AppKernel.php
:
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Symplify\ControllerAutowire\SymplifyControllerAutowireBundle(),
// ...
];
}
}
class SomeController
{
private $someClass;
public function __construct(SomeClass $someClass)
{
$this->someClass = $someClass;
}
}
That's all :)
vendor/bin/symplify-cs check src tests
vendor/bin/phpunit
Rules are simple:
- new feature needs tests
- all tests must pass
- 1 feature per PR
I'd be happy to merge your feature then.