{"id":22666901,"url":"https://github.com/piko-framework/event-dispatcher","last_synced_at":"2025-03-29T10:14:51.300Z","repository":{"id":62114447,"uuid":"557930118","full_name":"piko-framework/event-dispatcher","owner":"piko-framework","description":"A simple event dispatcher using a priority queue and compliant with the PSR-14","archived":false,"fork":false,"pushed_at":"2022-11-13T19:42:53.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T04:43:58.814Z","etag":null,"topics":[],"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/piko-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-26T15:12:35.000Z","updated_at":"2024-04-14T04:43:58.815Z","dependencies_parsed_at":"2023-01-21T16:16:06.257Z","dependency_job_id":null,"html_url":"https://github.com/piko-framework/event-dispatcher","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Fevent-dispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Fevent-dispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Fevent-dispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piko-framework%2Fevent-dispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piko-framework","download_url":"https://codeload.github.com/piko-framework/event-dispatcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246168109,"owners_count":20734390,"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-12-09T14:32:14.433Z","updated_at":"2025-03-29T10:14:51.271Z","avatar_url":"https://github.com/piko-framework.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Piko event-dispatcher\n\n[![Tests](https://github.com/piko-framework/event-dispatcher/actions/workflows/php.yml/badge.svg)](https://github.com/piko-framework/event-dispatcher/actions/workflows/php.yml)\n[![Coverage Status](https://coveralls.io/repos/github/piko-framework/event-dispatcher/badge.svg?branch=main)](https://coveralls.io/github/piko-framework/event-dispatcher?branch=main)\n\nThis package offers a simple event dispatcher using an event priority queue, following the [PSR-14](https://www.php-fig.org/psr/psr-14/) Event Dispatcher recommendation.\n\n## Installation\n\nVia Composer\n\n```bash\ncomposer require piko/event-dispatcher\n```\n\nThen ensure that the following file is included in your PHP project:\n\n```php\nrequire 'vendor/autoload.php'; // The Composer autoloader\n```\n\n## usage\n\n```php\nuse Piko\\Event;\nuse Piko\\ListenerProvider;\nuse Piko\\EventDispatcher;\n\nclass MyEvent extends \\Piko\\Event\n{\n    public $value;\n}\n\n$provider = new ListenerProvider();\n$dispatcher = new EventDispatcher($provider);\n$event = new MyEvent();\n\n$provider-\u003eaddListenerForEvent(MyEvent::class, function(MyEvent $event) {\n    $event-\u003evalue .= 'World !';\n});\n\n$provider-\u003eaddListenerForEvent(MyEvent::class, function(MyEvent $event) {\n    $event-\u003evalue .= 'Hello ';\n}, 10); // Set the priority to 10\n\n$dispatcher-\u003edispatch($event);\n\necho $event-\u003evalue; // Hello World!\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiko-framework%2Fevent-dispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiko-framework%2Fevent-dispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiko-framework%2Fevent-dispatcher/lists"}