event-dispatcher
Build status
Stability
License
This library is released under the MIT license. Please see attached LICENSE file.
Installation
Via Composer
Composer is the only supported way of installing aztech/event-dispatcher . Don't know Composer yet ? Read more about it.
$ composer require "aztech/event-dispatcher":"~1"
Autoloading
Add the following code to your bootstrap file :
require_once 'vendor/autoload.php';
Usage
As the name implies, event-dispatcher is a simple event dispatching library. Rather than a long speech, a simple example :
class MyEvent implements \Aztech\Events\Event
{
function getCategory() {
return 'my.event';
}
function getId() {
return 1;
}
}
$dispatcher = new \Aztech\Events\EventDispatcher();
$subscriber = new \Aztech\Events\Callback(function (\Aztech\Events\Event $event) {
echo 'I just received an event : ' . $event->getCategory() . PHP_EOL;
});
$dispatcher->addListener('my.#', $subscriber);
$dispatcher->dispatch(new MyEvent());Contributing
All contributions are welcome, via issues and pull requests.
When submitting a pull request, please ensure that your changes validate against the test suite and style checkers by running make test. All tests must pass (make must return 0).




