symplify / default-autowire
Adds autowire to services when needed.
Installs: 20 430
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.1
- symfony/config: ^3.2
- symfony/dependency-injection: ^3.2
- symfony/http-kernel: ^3.2
Requires (Dev)
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
- nette/finder: ^2.4
- nette/utils: ^2.4
- phpunit/phpunit: ^6.0
- symfony/form: ^3.2
- symfony/yaml: ^3.2
- tracy/tracy: ^2.4
This package is auto-updated.
Last update: 2022-03-08 10:48:45 UTC
README
This bundle turns on autowire for you!
It turns this:
# app/config/config.yml services: PriceCalculator: autowire: true ProductRepository: autowire: true UserFactory: autowire: true
Into this:
# app/config/config.yml services: PriceCalculator: ~ ProductRepository: ~ UserFactory: ~
Install
composer require symplify/default-autowire
Add bundle to AppKernel.php
:
final class AppKernel extends Kernel { public function registerBundles(): array { $bundles = [ new Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle(), // ... ]; } }
And that's it!
Features
Multiple service of one type? Set preferred one
In case you have multiple connections, entity managers or decorated service, you can set default preferred service (name) for each type (class or interface).
To make it easier for you, there are few default values. You can change them or add new ones.
# app/config/cofing.yml symplify_default_autowire: autowire_types: Doctrine\ORM\EntityManager: 'doctrine.orm.default_entity_manager' Doctrine\ORM\EntityManagerInterface: 'doctrine.orm.default_entity_manager' Doctrine\Portability\Connection: 'database_connection' Symfony\Component\EventDispatcher\EventDispatcher: 'event_dispatcher' Symfony\Component\EventDispatcher\EventDispatcherInterface: 'event_dispatcher' Symfony\Component\Translation\TranslatorInterface: 'translator'
Contributing
Send issue or pull-request to main repository.