aztech / event-dispatcher
Aztech Event Dispatcher
Installs: 1 553
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- psr/log: ~1
Requires (Dev)
- phpmd/phpmd: ~2.1
- phpunit/phpunit: ~4
- squizlabs/php_codesniffer: dev-phpcs-fixer
- vektah/bugfree-dangerzone: ~0.3
This package is auto-updated.
Last update: 2024-12-04 23:32:50 UTC
README
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).