{"id":21467392,"url":"https://github.com/elusivecodes/fyreevent","last_synced_at":"2025-07-15T05:31:25.170Z","repository":{"id":62508439,"uuid":"376248458","full_name":"elusivecodes/FyreEvent","owner":"elusivecodes","description":"FyreEvent is a free, open-source events library for PHP.","archived":false,"fork":false,"pushed_at":"2024-11-17T01:16:28.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T02:09:16.909Z","etag":null,"topics":["events","php"],"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/elusivecodes.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-12T09:18:28.000Z","updated_at":"2024-11-17T01:16:18.000Z","dependencies_parsed_at":"2024-06-29T02:41:07.234Z","dependency_job_id":null,"html_url":"https://github.com/elusivecodes/FyreEvent","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEvent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEvent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEvent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEvent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreEvent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017459,"owners_count":17560514,"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":["events","php"],"created_at":"2024-11-23T08:17:50.863Z","updated_at":"2025-07-15T05:31:25.150Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreEvent\r\n\r\n**FyreEvent** is a free, open-source events library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Events](#events)\r\n- [Event Listeners](#event-listeners)\r\n- [Event Dispatchers](#event-dispatchers)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/event\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Event\\EventManager;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$parentEventManager` is an *EventManager* that will handle propagated events, and will default to *null*.\r\n\r\n```php\r\n$eventManager = new EventManager($parentEventManager);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Add Listener**\r\n\r\nAdd an [*EventListener*](#event-listeners).\r\n\r\n- `$eventListener` is an [*EventListener*](#event-listeners).\r\n\r\n```php\r\n$eventManager-\u003eaddListener($eventListener);\r\n```\r\n\r\n**Clear**\r\n\r\nClear all events.\r\n\r\n```php\r\n$eventManager-\u003eclear();\r\n```\r\n\r\n**Dispatch**\r\n\r\nDispatch an [*Event*](#events).\r\n\r\n- `$event` is an [*Event*](#events).\r\n\r\n```php\r\n$eventManager-\u003edispatch($event);\r\n```\r\n\r\n**Has**\r\n\r\nCheck if an event exists.\r\n\r\n- `$name` is a string representing the event name.\r\n\r\n```php\r\n$hasEvent = $eventManager-\u003ehas($name);\r\n```\r\n\r\n**Off**\r\n\r\nRemove event(s).\r\n\r\n- `$name` is a string representing the event name.\r\n- `$callback` is the callback to remove.\r\n\r\n```php\r\n$eventManager-\u003eoff($name, $callback);\r\n```\r\n\r\nIf the `$callback` argument is omitted, all events will be removed instead.\r\n\r\n```php\r\n$eventManager-\u003eoff($name);\r\n```\r\n\r\n**On**\r\n\r\nAdd an event.\r\n\r\n- `$name` is a string representing the event name.\r\n- `$callback` is the callback to execute.\r\n- `$priority` is a number representing the callback priority, and will default to *EventManager::PRIORITY_NORMAL*.\r\n\r\n```php\r\n$eventManager-\u003eon($name, $callback, $priority);\r\n```\r\n\r\n**Remove Listener**\r\n\r\nRemove an [*EventListener*](#event-listeners).\r\n\r\n- `$eventListener` is an [*EventListener*](#event-listeners).\r\n\r\n```php\r\n$eventManager-\u003eremoveListener($eventListener);\r\n```\r\n\r\n**Trigger**\r\n\r\nTrigger an event.\r\n\r\n- `$name` is a string representing the event name.\r\n\r\nAny additional arguments supplied will be passed to the event callback.\r\n\r\n```php\r\n$event = $eventManager-\u003etrigger($name, ...$args);\r\n```\r\n\r\n\r\n## Events\r\n\r\n```php\r\nuse Fyre\\Event\\Event;\r\n```\r\n\r\n- `$name` is a string representing the name of the *Event* .\r\n- `$subject` is an object representing the *Event* subject, and will default to *null*.\r\n- `$data` is an array containing the *Event* data, and will default to *[]*.\r\n- `$cancelable` is a boolean indicating whether the event can be cancelled, and will default to *true*.\r\n\r\n```php\r\n$event = new Event($name, $subject, $data, $cancelable);\r\n```\r\n\r\n**Get Data**\r\n\r\nGet the *Event* data.\r\n\r\n```php\r\n$data = $event-\u003egetData();\r\n```\r\n\r\n**Get Name**\r\n\r\nGet the *Event* name.\r\n\r\n```php\r\n$name = $event-\u003egetName();\r\n```\r\n\r\n**Get Result**\r\n\r\nGet the *Event* result.\r\n\r\n```php\r\n$result = $event-\u003egetResult();\r\n```\r\n\r\n**Get Subject**\r\n\r\nGet the *Event* subject.\r\n\r\n```php\r\n$subject = $event-\u003egetSubject();\r\n```\r\n\r\n**Is Default Prevented**\r\n\r\nDetermine whether the default *Event* should occur.\r\n\r\n```php\r\n$isDefaultPrevented = $event-\u003eisDefaultPrevented();\r\n```\r\n\r\n**Is Propagation Stopped**\r\n\r\nDetermine whether the *Event* propagation was stopped.\r\n\r\n```php\r\n$isPropagationStopped = $event-\u003eisPropagationStopped();\r\n```\r\n\r\n**Is Stopped**\r\n\r\nDetermine whether the *Event* was stopped.\r\n\r\n```php\r\n$isStopped = $event-\u003eisStopped();\r\n```\r\n\r\n**Prevent Default**\r\n\r\nPrevent the default *Event*.\r\n\r\n```php\r\n$event-\u003epreventDefault();\r\n```\r\n\r\n**Set Data**\r\n\r\n- `$data` is an array containing the *Event* data.\r\n\r\n```php\r\n$event-\u003esetData($data);\r\n```\r\n\r\n**Set Result**\r\n\r\n- `$result` is the *Event* result.\r\n\r\n```php\r\n$event-\u003esetResult($result);\r\n```\r\n\r\n**Stop Immediate Propagation**\r\n\r\nStop the *Event* propagating immediately.\r\n\r\n```php\r\n$event-\u003estopImmediatePropagation();\r\n```\r\n\r\n**Stop Propagation**\r\n\r\nStop the *Event* propagating.\r\n\r\n```php\r\n$event-\u003estopPropagation();\r\n```\r\n\r\n\r\n## Event Listeners\r\n\r\nCustom event listeners can be created by implementing the `Fyre\\Event\\EventListenerInterface`, ensuring all below methods are implemented.\r\n\r\n```php\r\nuse Fyre\\Event\\EventListenerInterface;\r\n\r\nclass MyListener implements EventListenerInterface\r\n{\r\n\r\n}\r\n```\r\n\r\n**Implemented Events**\r\n\r\nGet the implemented events.\r\n\r\n```php\r\n$events = $listener-\u003eimplementedEvents();\r\n```\r\n\r\n\r\n## Event Dispatchers\r\n\r\nCustom event dispatchers can be created by using the `Fyre\\Event\\EventDispatcherTrait`.\r\n\r\n```php\r\nuse Fyre\\Event\\EventDispatcherTrait;\r\n\r\nclass MyDispatcher\r\n{\r\n    use EventDispatcherTrait;\r\n}\r\n```\r\n\r\n**Dispatch Event**\r\n\r\nDispatch an [*Event*](#events).\r\n\r\n- `$name` is a string representing the event name.\r\n- `$data` is an array containing the *Event* data, and will default to *[]*.\r\n- `$subject` is an object representing the *Event* subject, and will default to the event dispatcher.\r\n- `$cancelable` is a boolean indicating whether the event can be cancelled, and will default to *true*.\r\n\r\n```php\r\n$this-\u003edispatchEvent($name, $data, $subject, $cancelable);\r\n```\r\n\r\n**Get Event Manager**\r\n\r\nGet the *EventManager*.\r\n\r\n```php\r\n$eventManager = $this-\u003egetEventManager();\r\n```\r\n\r\n**Set Event Manager**\r\n\r\nSet the *EventManager*.\r\n\r\n- `$eventManager` is an *EventManager*.\r\n\r\n```php\r\n$this-\u003esetEventManager($eventManager);\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreevent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyreevent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreevent/lists"}