{"id":18337430,"url":"https://github.com/mikemix/eventdispatcher","last_synced_at":"2025-04-09T20:17:25.763Z","repository":{"id":17827700,"uuid":"20731117","full_name":"mikemix/eventdispatcher","owner":"mikemix","description":"Easily attach listeners to ZF2's MVC events","archived":false,"fork":false,"pushed_at":"2015-06-22T20:33:02.000Z","size":240,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-09T20:17:21.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikemix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-11T15:47:38.000Z","updated_at":"2015-06-22T20:26:21.000Z","dependencies_parsed_at":"2022-09-10T18:03:27.177Z","dependency_job_id":null,"html_url":"https://github.com/mikemix/eventdispatcher","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemix%2Feventdispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemix%2Feventdispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemix%2Feventdispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemix%2Feventdispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikemix","download_url":"https://codeload.github.com/mikemix/eventdispatcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103860,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:11:11.768Z","updated_at":"2025-04-09T20:17:25.741Z","avatar_url":"https://github.com/mikemix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"EventDispatcher\n===============\n\nThis module is old, crappy and unmaintained, so please don't use it :)\n======================================================================\n\nEasily attach listeners to ZF2's MVC events.\n\nInstallation\n------------\n\n1. Add ```\"mikemix/eventdispatcher\": \"1.*\"``` to your composer.json file\n2. Run ```php composer.phar self-update \u0026\u0026 php composer.phar update```\n3. Add module ```EventDispatcher``` to your application modules in the ```application.config.php``` file\n4. Copy file ```vendor/mikemix/eventdispatcher/config/event_dispatcher.global.php.dist``` to the ```config/autoload/event_dispatcher.global.php```\n\nCongratulations. 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.\n\nExample configuration\n---------------------\n\nFile ```config/autoload/event_dispatcher.config.php```\n\n```php\nreturn array(\n    'event_dispatcher' =\u003e array(\n        'dispatch' =\u003e array(\n            // dispatch listeners here\n            'myDispatchListener'       # \u003c----------------- NOTICE\n        ),\n        'dispatch.error' =\u003e array(\n            // dispatch.error listeners here\n        ),\n        'finish' =\u003e array(\n            // finish listeners here\n        ),\n        'render' =\u003e array(\n            // render listeners here\n        ),\n        'render.error' =\u003e array(\n            // render.error listeners here\n        ),\n        'route' =\u003e array(\n            // route listeners here\n        ),\n    ),\n);\n```\n\nFile ```module/Application/config/module.config.php```\n\n```php\n// ...\n'service_manager' =\u003e array(\n    // ...\n    \n    'invokables' =\u003e array(\n        'myDispatchListener' =\u003e 'Application\\Listener\\DispatchListener',\n    ),\n),\n```\n\nFile ```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.\n\n```php\n\u003c?php\nnamespace Application\\Listener;\n\nuse EventDispatcher\\Listener\\ListenerInterface;\n\nclass DispatchListener implements ListenerInterface\n{\n    public function onEvent(EventInterface $event)\n    {\n        printf('Well hello, a %s event was called', $event-\u003egetName());\n    }\n}\n```\n\n\nValuable resources about ZF2 events on the net\n----------------------------------------------\n\n   * http://framework.zend.com/manual/2.3/en/modules/zend.mvc.mvc-event.html\n   * http://www.michaelgallego.fr/blog/2013/05/12/understanding-the-zend-framework-2-event-manager/\n   * http://mwop.net/blog/266-Using-the-ZF2-EventManager.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemix%2Feventdispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikemix%2Feventdispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemix%2Feventdispatcher/lists"}