DefaultAutowire
[DEPRECATED] Use Symfony 3.3 instead, see →
Install / Use
/learn @deprecated-packages/DefaultAutowireREADME
Default Autowire
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.
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
