{"id":34938943,"url":"https://github.com/phpnomad/event","last_synced_at":"2026-05-22T15:40:35.400Z","repository":{"id":244274147,"uuid":"701793304","full_name":"phpnomad/event","owner":"phpnomad","description":"Interfaces for event-driven architecture — broadcast, listen, handle, and bind events without coupling","archived":false,"fork":false,"pushed_at":"2026-04-10T02:09:13.000Z","size":122,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-10T04:11:33.001Z","etag":null,"topics":["event-driven","events","framework","observer-pattern","php","phpnomad","platform-agnostic","pub-sub"],"latest_commit_sha":null,"homepage":"https://phpnomad.com","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/phpnomad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-07T15:17:13.000Z","updated_at":"2026-04-10T02:09:17.000Z","dependencies_parsed_at":"2024-06-13T19:56:11.945Z","dependency_job_id":"3a8fd66a-f0be-4fda-8b87-9d09b2deb358","html_url":"https://github.com/phpnomad/event","commit_stats":null,"previous_names":["phpnomad/event"],"tags_count":1,"template":false,"template_full_name":"phpnomad/repository-template","purl":"pkg:github/phpnomad/event","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpnomad%2Fevent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpnomad%2Fevent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpnomad%2Fevent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpnomad%2Fevent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpnomad","download_url":"https://codeload.github.com/phpnomad/event/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpnomad%2Fevent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33349937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"online","status_checked_at":"2026-05-22T02:00:06.671Z","response_time":265,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["event-driven","events","framework","observer-pattern","php","phpnomad","platform-agnostic","pub-sub"],"created_at":"2025-12-26T18:49:09.158Z","updated_at":"2026-05-22T15:40:35.395Z","avatar_url":"https://github.com/phpnomad.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phpnomad/event\n\n[![Latest Version](https://img.shields.io/packagist/v/phpnomad/event.svg)](https://packagist.org/packages/phpnomad/event)\n[![Total Downloads](https://img.shields.io/packagist/dt/phpnomad/event.svg)](https://packagist.org/packages/phpnomad/event)\n[![PHP Version](https://img.shields.io/packagist/php-v/phpnomad/event.svg)](https://packagist.org/packages/phpnomad/event)\n[![License](https://img.shields.io/packagist/l/phpnomad/event.svg)](https://packagist.org/packages/phpnomad/event)\n\n`phpnomad/event` provides interfaces for event-driven architecture in PHP applications. Components broadcast events when something happens, and listeners react without the publisher needing to know who is listening. That lets you add behavior like sending a welcome email, updating a cache, or writing an audit log by writing a new handler instead of modifying existing code.\n\nThis package is interfaces only. It has zero runtime dependencies and it does not ship a dispatcher. For a working event system you also install a concrete implementation. The recommended one is [`phpnomad/symfony-event-dispatcher-integration`](https://packagist.org/packages/phpnomad/symfony-event-dispatcher-integration), which adapts Symfony's EventDispatcher to the `EventStrategy` contract. The package is used in production by [Siren](https://sirenaffiliates.com) and by every PHPNomad package that needs to broadcast or listen for events.\n\n## Installation\n\n```bash\ncomposer require phpnomad/event\n```\n\nFor a working dispatcher, also install the Symfony integration:\n\n```bash\ncomposer require phpnomad/symfony-event-dispatcher-integration\n```\n\n## Quick Start\n\nDefine an event. It just needs a stable identifier and whatever payload you want handlers to see.\n\n```php\nuse PHPNomad\\Events\\Interfaces\\Event;\n\nclass UserCreatedEvent implements Event\n{\n    public function __construct(\n        public readonly int $userId,\n        public readonly string $email\n    ) {}\n\n    public static function getId(): string\n    {\n        return 'user.created';\n    }\n}\n```\n\nWrite a handler that reacts to the event.\n\n```php\nuse PHPNomad\\Events\\Interfaces\\CanHandle;\nuse PHPNomad\\Events\\Interfaces\\Event;\n\nclass SendWelcomeEmailHandler implements CanHandle\n{\n    public function __construct(private EmailService $email) {}\n\n    public function handle(Event $event): void\n    {\n        $this-\u003eemail-\u003esend($event-\u003eemail, 'Welcome!');\n    }\n}\n```\n\nDeclare the event-to-handler mapping on a module so the bootstrapper can wire it up.\n\n```php\nuse PHPNomad\\Events\\Interfaces\\HasListeners;\n\nclass UserModule implements HasListeners\n{\n    public function getListeners(): array\n    {\n        return [\n            UserCreatedEvent::class =\u003e SendWelcomeEmailHandler::class,\n        ];\n    }\n}\n```\n\nBroadcast the event from wherever the state change actually happens.\n\n```php\nuse PHPNomad\\Events\\Interfaces\\EventStrategy;\n\nclass UserService\n{\n    public function __construct(private EventStrategy $events) {}\n\n    public function createUser(string $email): User\n    {\n        $user = new User($email);\n        // persist the user...\n\n        $this-\u003eevents-\u003ebroadcast(new UserCreatedEvent(\n            userId: $user-\u003egetId(),\n            email: $user-\u003egetEmail()\n        ));\n\n        return $user;\n    }\n}\n```\n\nThe `UserService` has no knowledge of `SendWelcomeEmailHandler`. Adding a second handler for logging, analytics, or a Slack notification is a new class and one extra line in `getListeners()`. The service code does not change.\n\n## Key Concepts\n\n- `Event`: an object representing something that happened, identified by a static `getId()` string\n- `EventStrategy`: the dispatcher interface with `broadcast()`, `attach()`, and `detach()`\n- `CanHandle`: the contract a handler implements to react to an event\n- `HasListeners`: modules implement this to declare their event-to-handler mappings\n- `HasEventBindings`: flexible binding configuration for platform integration layers\n- `ActionBindingStrategy`: bridges external systems like WordPress hooks into application events\n\n## Documentation\n\nFull documentation, including the interface reference and event design best practices, lives at [phpnomad.com](https://phpnomad.com).\n\n## License\n\nMIT. See [LICENSE.txt](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpnomad%2Fevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpnomad%2Fevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpnomad%2Fevent/lists"}