{"id":21688466,"url":"https://github.com/parable-php/event","last_synced_at":"2025-04-12T09:21:34.855Z","repository":{"id":57035822,"uuid":"144422832","full_name":"parable-php/event","owner":"parable-php","description":"Parable Event is a straightforward and minimalist event system.","archived":false,"fork":false,"pushed_at":"2021-03-12T15:25:05.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T13:42:32.175Z","etag":null,"topics":["event","events","hook","listeners","micro","observers","parable","php8","triggers"],"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/parable-php.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-08-11T22:48:07.000Z","updated_at":"2024-07-24T12:04:33.000Z","dependencies_parsed_at":"2022-08-24T14:10:27.068Z","dependency_job_id":null,"html_url":"https://github.com/parable-php/event","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parable-php%2Fevent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parable-php%2Fevent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parable-php%2Fevent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parable-php%2Fevent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parable-php","download_url":"https://codeload.github.com/parable-php/event/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248544038,"owners_count":21121881,"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":["event","events","hook","listeners","micro","observers","parable","php8","triggers"],"created_at":"2024-11-25T17:15:18.290Z","updated_at":"2025-04-12T09:21:34.828Z","avatar_url":"https://github.com/parable-php.png","language":"PHP","readme":"# Parable Event\n\n[![Workflow Status](https://github.com/parable-php/event/workflows/Tests/badge.svg)](https://github.com/parable-php/event/actions?query=workflow%3ATests)\n[![Latest Stable Version](https://poser.pugx.org/parable-php/event/v/stable)](https://packagist.org/packages/parable-php/event)\n[![Latest Unstable Version](https://poser.pugx.org/parable-php/event/v/unstable)](https://packagist.org/packages/parable-php/event)\n[![License](https://poser.pugx.org/parable-php/event/license)](https://packagist.org/packages/parable-php/event)\n\nParable Event is a straightforward event system that gets the job done.\n\n## Install\n\nPhp 8.0+ and [composer](https://getcomposer.org) are required.\n\n```bash\n$ composer require parable-php/event\n```\n\n## Usage\n\nEvents are very simple. You add listeners to events (`string` values) and then trigger an update with those events. You \ncan pass payloads into the `trigger` calls, which will get passed to all relevant listeners.\n\n```php\nuse \\Parable\\Event\\Events;\n\n$eventManager = new Events();\n\n$eventManager-\u003elisten('event_number_one', function (string $event, string \u0026$payload) {\n    $payload .= '-updated!';\n});\n\n$payload = 'event';\n\n$eventManager-\u003etrigger('event_number_one', $payload);\n\necho $payload;\n\n// output: 'event-updated!'\n```\n\nThe above example handily shows how to make scalar values modifiable by defining the parameter to the callable as a\nreference. Passing objects is generally advisable, but sometimes it's the in-place alteration of string values you\nneed.\n\nIt's also possible to have a listener trigger on every single event.\n\n```php\n$eventManager-\u003elistenAll(function (string $event, $payload) {\n    echo $event . PHP_EOL;\n});\n``` \n\nThe above example would simply log all events being updated. This can be handy for debugging, but can also be handy\nto listen to a specific subset of events by matching the event, rather than adding a single listener to all individual\nevents. \n\n## API\n\n- `listen(string $event, callable $$listener): void` - add listener to an event\n- `listenAll(callable $$listener): void` - add listener for all events\n- `trigger(string $event, $payload): void` - trigger an update for an event\n\n## Contributing\n\nAny suggestions, bug reports or general feedback is welcome. Use github issues and pull requests, or find me over at [devvoh.com](https://devvoh.com).\n\n## License\n\nAll Parable components are open-source software, licensed under the MIT license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparable-php%2Fevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparable-php%2Fevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparable-php%2Fevent/lists"}