https://github.com/antidot-framework/antidot-event-dispatcher
Lightweight Event dispatcher library compatible with PSR container
https://github.com/antidot-framework/antidot-event-dispatcher
event-dispatcher psr-14
Last synced: 2 months ago
JSON representation
Lightweight Event dispatcher library compatible with PSR container
- Host: GitHub
- URL: https://github.com/antidot-framework/antidot-event-dispatcher
- Owner: antidot-framework
- License: bsd-2-clause
- Created: 2019-04-04T19:06:17.000Z (about 6 years ago)
- Default Branch: 3.x.x
- Last Pushed: 2021-12-06T12:10:37.000Z (over 3 years ago)
- Last Synced: 2025-04-02T04:03:32.054Z (3 months ago)
- Topics: event-dispatcher, psr-14
- Language: PHP
- Homepage: https://event-dispatcher.antidotfw.io
- Size: 114 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Antidot event dispatcher
[](https://scrutinizer-ci.com/g/antidot-framework/antidot-event-dispatcher/?branch=master)
[](https://scrutinizer-ci.com/g/antidot-framework/antidot-event-dispatcher/?branch=master)
[](https://infection.github.io)
[](https://shepherd.dev/github/antidot-framework/antidot-event-dispatcher)
[](https://scrutinizer-ci.com/g/antidot-framework/antidot-event-dispatcher/build-status/3.x.x)
[](https://codeclimate.com/github/kpicaza/antidot-event-dispatcher/maintainability)[Psr 14 Event dispatcher](https://github.com/php-fig/event-dispatcher) implementation.
## Installation
Using [composer](https://getcomposer.org/download/)
```bash
composer require antidot-fw/event-dispatcher
```### Using [Laminas config Aggregator](https://docs.laminas.dev/laminas-config-aggregator/)
it install the library automatically

### Using factory:
#### Config
```php
set('config', [
'app-events' => [
'event-listeners' => [
// SomeEvent::class => [
'some.event' => [
SomeEventListener::class,
SomeEventOtherListener::class,
]
]
]
]);
```
#### factory```php
__invoke($container);
$container->set(EventDispatcherInterface::class, $eventDispatcher);
```#### Async Event Dispatcher Factory
```bash
composer require react/event-loop
``````php
__invoke($container);
$container->set(EventDispatcherInterface::class, $eventDispatcher);
```## Usage
### Send events
```php
get(EventDispatcherInterface::class);$eventDispatcher->dispatch(SomeEvent::occur());
```### Send events Async mode
```php
get(EventDispatcherInterface::class);$eventDispatcher->dispatch(SomeEvent::occur());
Loop::run()
```