chacal / silex-di-builder
A simple dependency injection builder to Silex
Installs: 40
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/chacal/silex-di-builder
Requires
- php: >=5.6
- deralex/yaml-config-service-provider: ~1.0
Requires (Dev)
- phpunit/phpunit: ^4.8
- silex/silex: 1.*@dev
This package is not auto-updated.
Last update: 2025-10-04 01:05:52 UTC
README
A simple dependency injection builder to Silex based on YAML file config.
Install
composer require chacal/silex-di-builder
Usage
Simple create a di.yml - or other name, of course - file with the structure:
services:
alias1:
- Full\Class\Name
- dependency1
alias2:
- Full\ClassTwo\Name
- dependency1
- dependency2
When:
- alias1 - Is the alias from Silex
- Full\Class\Name and Full\ClassTwo\Name - The class name to initialize
- dependency1 and dependecy2 - Dependencies from the class, must be an alias previously created
In your application bootstrap, register YAML Config Service Provider, with your DI file
use DerAlex\Silex\YamlConfigServiceProvider;
use MrPrompt\Silex\Di\Container as DiServiceProvider;
....
$app->register(new YamlConfigServiceProvider(__DIR__ . '/../Resources/di.yml'));
$app->register(new DiServiceProvider());
Now, your services is available on $app container.
Testing
Just run phpunit without parameters
phpunit
Happy Silex Coding :)