symnedi / event-dispatcher
Symfony\EventDispatcher integration to Nette.
Installs: 125 230
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.6
- nette/di: ~2.3
- nette/http: ~2.3
- symfony/event-dispatcher: ~2.7
Requires (Dev)
- kdyby/console: ~2.4
- kdyby/events: ~2.4|~3.0
- nette/application: ~2.3
- nette/bootstrap: ~2.3
- phpunit/phpunit: ^5.0
- tracy/tracy: ~2.3
README
Integration of Symfony\EventDispatcher into Nette\DI.
Install
$ composer require symnedi/event-dispatcher
Register the extension in config.neon
:
extensions: - Symnedi\EventDispatcher\DI\EventDispatcherExtension
Usage
There are 3 important parts using EventDispatcher:
- Event
- EventSubscriber
- EventDispatcher
Event is value object, it simply stores data we use - e.g. user email and password.
EventSubscriber listens to certain event and invokes some action, when that happens - when user logs in.
EventDispatcher invokes the event in the place where it happens - in the login form just after the login method.
To see the real code in practise, there is example section with both Event and EventSubscriber.
Also you can find AppEvents.php
that basically lists all used events. It's not necessary for the starters, just convenient in huge applications.
For more details, check Symfony documentation, or this very nice presentation with real-life examples.
Testing
$ phpunit
Contributing
Please see CONTRIBUTING for details.