symplify / auto-bind-parameter
Auto bind parameters for your Symfony applications
Fund package maintenance!
tomasvotruba
www.paypal.me/rectorphp
Requires
- php: >=7.2
- nette/utils: ^3.0
- symfony/dependency-injection: ^4.4|^5.1
- symfony/http-kernel: ^4.4|^5.1
Requires (Dev)
- phpunit/phpunit: ^8.5|^9.0
- symplify/package-builder: ^8.3.16
- dev-master / 8.4.x-dev
- 8.3.16
- 8.3.15
- 8.3.14
- 8.3.13
- 8.3.12
- 8.3.11
- 8.3.10
- 8.3.7
- 8.3.6
- 8.3.5
- 8.3.4
- 8.3.3
- 8.3.2
- 8.3.1
- 8.3.0
- 8.2.27
- 8.2.26
- 8.2.25
- 8.2.24
- 8.2.22
- 8.2.21
- 8.2.20
- 8.2.19
- 8.2.18
- 8.2.17
- v8.2.16
- v8.2.15
- v8.2.14
- v8.2.13
- v8.2.12
- v8.2.11
- v8.2.10
- v8.2.9
- v8.2.8
- v8.2.7
- v8.2.6
- v8.2.5
- v8.2.4
- v8.2.3
- v8.2.2
- v8.2.1
- v8.2.0
- v8.1.20
- v8.1.19
- v8.1.18
- v8.1.17
- v8.1.16
- v8.1.15
- v8.1.14
- v8.1.13
- v8.1.12
- v8.1.11
- v8.1.10
- v8.1.9
- v8.1.8
- v8.1.7
- v8.1.6
- v8.1.4
- v8.1.3
- v8.1.2
- v8.1.1
- v8.1.0
- v8.0.1
- v8.0.0
- v8.0.0-beta4
- v8.0.0-beta3
- v8.0.0-beta2
- v8.0.0-beta1
- v7.3.18
- v7.3.17
- v7.3.16
- v7.3.15
- v7.3.14
- v7.3.13
- v7.3.11
- v7.3.10
- v7.3.9
- v7.3.8
- v7.3.7
- v7.3.6
- v7.3.5
- v7.3.4
- v7.3.3
- v7.3.2
- v7.3.1
- v7.3.0
- v7.2.20
- v7.2.19
- v7.2.18
- v7.2.17
- v7.2.16
- v7.2.15
- v7.2.14
- v7.2.13
- v7.2.12
- v7.2.11
- v7.2.10
- v7.2.8
- v7.2.7
- v7.2.6
- v7.2.5
- v7.2.4
- v7.2.3
- v7.2.2
- v7.2.1
- v7.2.0
- dev-symplify7
This package is auto-updated.
Last update: 2020-09-29 15:16:56 UTC
README
*Deprecated: instead of magic parameter binding, use ParameterProvider with constants
Install
composer require symplify/auto-bind-parameter
Usage
1. Register Compiler Pass in kernel
<?php declare(strict_types=1); namespace App; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel; use Symplify\AutoBindParameter\DependencyInjection\CompilerPass\AutoBindParameterCompilerPass; class AppKernel extends Kernel { protected function build(ContainerBuilder $containerBuilder): void { $containerBuilder->addCompilerPass(new AutoBindParameterCompilerPass()); } }
2. Auto Bind Parameters
Keep your configs simple enough:
parameters: entity_repository_class: 'Doctrine\ORM\EntityRepository' entity_manager_class: 'Doctrine\ORM\EntityManager' services: - _defaults: - bind: - $entityRepositoryClass: '%entity_repository_class%' - $entityManagerClass: '%entity_manager_class%' - Rector\: resource: ..
And as any other bind:
<?php declare(strict_types=1); class SomeClass { /** * @var string */ private $entityRepositoryClass; public function __construct(string $entityRepositoryClass) { $this->entityRepositoryClass = $entityRepositoryClass; } }