{"id":33217087,"url":"https://github.com/aneek/slim-event-dispatcher","last_synced_at":"2026-01-31T16:17:28.585Z","repository":{"id":56948244,"uuid":"104748622","full_name":"aneek/slim-event-dispatcher","owner":"aneek","description":"An event dispatcher bridge with League Event","archived":false,"fork":false,"pushed_at":"2017-09-27T08:01:28.000Z","size":11,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"1.x","last_synced_at":"2025-11-09T17:24:42.751Z","etag":null,"topics":["emitter","event","event-dispatcher","league-event","listener","slim-framework"],"latest_commit_sha":null,"homepage":null,"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/aneek.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":"2017-09-25T12:43:46.000Z","updated_at":"2022-08-23T22:42:52.000Z","dependencies_parsed_at":"2022-08-21T08:20:14.395Z","dependency_job_id":null,"html_url":"https://github.com/aneek/slim-event-dispatcher","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aneek/slim-event-dispatcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneek%2Fslim-event-dispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneek%2Fslim-event-dispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneek%2Fslim-event-dispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneek%2Fslim-event-dispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aneek","download_url":"https://codeload.github.com/aneek/slim-event-dispatcher/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneek%2Fslim-event-dispatcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28947573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["emitter","event","event-dispatcher","league-event","listener","slim-framework"],"created_at":"2025-11-16T14:00:18.871Z","updated_at":"2026-01-31T16:17:28.580Z","avatar_url":"https://github.com/aneek.png","language":"PHP","funding_links":[],"categories":["Packages and Middleware"],"sub_categories":["Videos"],"readme":"# Slim Event Dispatcher\n\n[![Build Status](https://travis-ci.org/aneek/slim-event-dispatcher.svg?branch=develop)](https://travis-ci.org/aneek/slim-event-dispatcher)\n\nThis library is an implementation of ```League\\Event``` for ```Slim Framework```. This works with the latest version of Slim (V3).\n\n## Installation\nIt's recommended that you use [Composer](https://getcomposer.org/) to install Slim Event Dispatcher.\n\n```bash\n$ composer require aneek/slim-event-dispatcher \"^1.0\"\n```\nThis will install Slim Event Dispatcher and all required dependencies. This package requires PHP 5.6 or newer. Though version 1.x is not recommended for PHP 7.0 and above. The next major version (v2.x) will support PHP 7.x.\n\n## Usage\nThis is not a Slim Middleware but a package which integrates with your Slim application by extending the ```SlimEventManager``` class and adding it to Slim's dependency container. Currently there are two ways of integration.\n\n### Using Class Constructor\n```Slim\\Event\\SlimEventManager``` class accepts an array argument in it's constructor and initializes all Listeners (more information on [listeners](http://event.thephpleague.com/2.0/listeners/callables/)).\n\nThe below file content serves as a application loader file for Slim Framework:\n\n```php\n\u003c?php\n\nuse Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse Psr\\Http\\Message\\ResponseInterface as Response;\nuse Slim\\Container;\nuse Slim\\App;\nuse Slim\\Event\\SlimEventManager;\n\nrequire 'vendor/autoload.php';\n\n$settings = [\n    'settings' =\u003e [\n        'determineRouteBeforeAppMiddleware' =\u003e true,\n        'displayErrorDetails' =\u003e true,\n    ],\n];\n\n// Array of event Listeners\n$events = [\n    'event.one' =\u003e [\n        // First element is the FQCN class. This element is mandatory.\n        // Second element is the listener priority but this is not mandatory.\n        [\\FooListener::class, 100],\n        [\\BarListener::class]    \n    ],\n    'event.two' =\u003e [\n        [\\BazListener::class]\n    ]\n];\n\n$container = new Container();\n$container['event_manager'] = function ($c) use($events) {\n    $emitter = new SlimEventManager($events);\n    return $emitter;\n};\n\n$app = new App($container);\n\n$app-\u003eget('/hello/{name}', function (Request $request, Response $response, $args) {\n    $this-\u003eget('event_manager')-\u003eemit('event.one', 'parameter_one', 'parameter_two');\n    return $response-\u003ewrite(\"Hello, \" . $args['name']);\n});\n\n$app-\u003erun();\n```\n\n### Using ``add`` Method with Callable\n\n```php\n\u003c?php\n\nuse Psr\\Http\\Message\\ServerRequestInterface as Request;\nuse Psr\\Http\\Message\\ResponseInterface as Response;\nuse Slim\\Container;\nuse Slim\\App;\nuse Slim\\Event\\SlimEventManager;\n\nrequire 'vendor/autoload.php';\n\n$settings = [\n    'settings' =\u003e [\n        'determineRouteBeforeAppMiddleware' =\u003e true,\n        'displayErrorDetails' =\u003e true,\n    ],\n];\n\n\n$container = new Container();\n// Add Event manager to dependency.\n$container['event_manager'] = function ($c) {\n    $emitter = new SlimEventManager();\n    return $emitter;\n};\n\n$app = new App($container);\n\n$app-\u003egetContainer()-\u003eget('event_manager')-\u003eadd('event.one', function ($event, $param_1, $param_2) {\n    // Do processing of the event.\n    echo $param_1; // Prints parameter_one\n    echo $param_2; // Prints parameter_two\n});\n\n\n$app-\u003eget('/hello/{name}', function (Request $request, Response $response, $args) {\n    $this-\u003eget('event_manager')-\u003eemit('event.one', 'parameter_one', 'parameter_two');\n    return $response-\u003ewrite(\"Hello, \" . $args['name']);\n});\n\n$app-\u003erun();\n```\n\n## Creating Events or Listeners\n``Events`` or ``Listeners`` can be created by following the below guides from ``League\\Event``.\n\n- Event creation [guide](http://event.thephpleague.com/2.0/events/named/).\n- Listener creation [guide](http://event.thephpleague.com/2.0/listeners/callables/).\n\n## Issues\nPlease open a new issue and I will be happy to look into it.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneek%2Fslim-event-dispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faneek%2Fslim-event-dispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneek%2Fslim-event-dispatcher/lists"}