jonsa / silex-ioc
IoC for Silex application
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jonsa/silex-ioc
Requires
- jonsa/pimple-ioc: 1.3.*
- silex/silex: ~2.0@dev
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is not auto-updated.
Last update: 2025-10-26 00:34:55 UTC
README
Class resolver for the Silex application.
This project is a bridge between Pimple IoC and the Silex Application.
Installation
Add the IoC container to your composer.json using the command line.
composer require jonsa/silex-ioc
Usage
The class resolver is registered in Silex as a ServiceProvider
use Jonsa\PimpleResolver\ServiceProvider as PimpleResolverServiceProvider; use Jonsa\SilexResolver\ServiceProvider as SilexResolverServiceProvider; use Silex\Application; $app = new Application(); $app->register(new PimpleResolverServiceProvider()); $app->register(new SilexResolverServiceProvider());
Events
The Silex event dispatcher is registered with PimpleResolver which makes it easy to inject into the resolver.
use Jonsa\PimpleResolver\Event\ClassResolvedEvent; use Jonsa\PimpleResolver\Events as ResolverEvents; $app->on(ResolverEvents::CLASS_RESOLVED, function (ClassResolvedEvent $event) { $object = $event->getResolvedObject(); ... });
Configuration
The ServiceProvider has one configuration parameter.
class ServiceProvider implements ServiceProviderInterface { public function __construct($resolveControllers = true) { ... } }
$resolveControllers tells the ServiceProvider whether to replace the built-in controller resolver in Silex. If set to true controllers will be resolved out of the IoC container.