Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Symfony compatible event dispatcher that allows services to be lazy loaded from an instance of a Pimple DI container
PHP
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/PimpleAwareEventDispatcher
tests/PimpleAwareEventDispatcher/Test
.gitignore
LICENCE
README.md
composer.json
phpunit.xml.dist

README.md

Pimple Aware Event Dispatcher

Installation

composer.phar require "davedevelopment/pimple-aware-event-dispatcher:*@dev"

Usage

To use in a Silex application:

<?php

use PimpleAwareEventDispatcher\PimpleAwareEventDispatcher;
use Silex\Application;

$app = new Application;

// override the dispatcher
$app['dispatcher'] = $app['pimple_aware_dispatcher'] = $app->share(
    $app->extend('dispatcher', function($dispatcher) use ($app) {
        return new PimpleAwareEventDispatcher($dispatcher, $app);
    }
));

// define our application services
$app['some.service'] = $app->share(function() use ($app) {
    // let's assume this takes a bit of doing and/or is dependant on several other
    // services
    sleep(1);
    return new SomeService;
});

// add a listener, that will lazily fetch the service when needed
$app['pimple_aware_dispatcher']->addListenerService(
    "some.event",
    array("some.service", "serviceMethod")
);
Something went wrong with that request. Please try again.