Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikemix/eventdispatcher
Easily attach listeners to ZF2's MVC events
https://github.com/mikemix/eventdispatcher
Last synced: 17 days ago
JSON representation
Easily attach listeners to ZF2's MVC events
- Host: GitHub
- URL: https://github.com/mikemix/eventdispatcher
- Owner: mikemix
- License: mit
- Created: 2014-06-11T15:47:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-22T20:33:02.000Z (over 9 years ago)
- Last Synced: 2024-11-05T20:16:47.542Z (2 months ago)
- Language: PHP
- Homepage:
- Size: 234 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
EventDispatcher
===============This module is old, crappy and unmaintained, so please don't use it :)
======================================================================Easily attach listeners to ZF2's MVC events.
Installation
------------1. Add ```"mikemix/eventdispatcher": "1.*"``` to your composer.json file
2. Run ```php composer.phar self-update && php composer.phar update```
3. Add module ```EventDispatcher``` to your application modules in the ```application.config.php``` file
4. Copy file ```vendor/mikemix/eventdispatcher/config/event_dispatcher.global.php.dist``` to the ```config/autoload/event_dispatcher.global.php```Congratulations. You are done and the library has been successfully installed (hope so). To subscribe to a mvc event, it is as simple as adding a name of your listener service name to the ```event_dispatcher.global.php``` file. The name must be recognized by the service manager.
Example configuration
---------------------File ```config/autoload/event_dispatcher.config.php```
```php
return array(
'event_dispatcher' => array(
'dispatch' => array(
// dispatch listeners here
'myDispatchListener' # <----------------- NOTICE
),
'dispatch.error' => array(
// dispatch.error listeners here
),
'finish' => array(
// finish listeners here
),
'render' => array(
// render listeners here
),
'render.error' => array(
// render.error listeners here
),
'route' => array(
// route listeners here
),
),
);
```File ```module/Application/config/module.config.php```
```php
// ...
'service_manager' => array(
// ...
'invokables' => array(
'myDispatchListener' => 'Application\Listener\DispatchListener',
),
),
```File ```module/Application/src/Application/Listener/DispatchListener.php```. For your convienience and type hinting in the editor of your choice, you can make listener implement the ListenerInterface interface, but you are not obliged to. Just make sure an ```onEvent()``` method is callable.
```php
getName());
}
}
```Valuable resources about ZF2 events on the net
----------------------------------------------* http://framework.zend.com/manual/2.3/en/modules/zend.mvc.mvc-event.html
* http://www.michaelgallego.fr/blog/2013/05/12/understanding-the-zend-framework-2-event-manager/
* http://mwop.net/blog/266-Using-the-ZF2-EventManager.html