{"id":20187951,"url":"https://github.com/commonphp/events","last_synced_at":"2025-11-28T14:06:40.061Z","repository":{"id":222933485,"uuid":"758761890","full_name":"commonphp/events","owner":"commonphp","description":"A powerful and flexible system to handle event-driven programming within PHP applications. It provides mechanisms for event registration, de-registration, triggering, and dynamic hook management.","archived":false,"fork":false,"pushed_at":"2024-02-17T03:53:15.000Z","size":9,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-13T18:24:33.577Z","etag":null,"topics":["commonphp","event-listeners","event-management","events","hooks","open-source","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/commonphp.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":"2024-02-17T02:34:05.000Z","updated_at":"2024-02-17T18:35:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a9cc1a2-7849-4950-80a8-a8a034f2ea26","html_url":"https://github.com/commonphp/events","commit_stats":null,"previous_names":["commonphp/events"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commonphp%2Fevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commonphp","download_url":"https://codeload.github.com/commonphp/events/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241622613,"owners_count":19992504,"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":["commonphp","event-listeners","event-management","events","hooks","open-source","php"],"created_at":"2024-11-14T03:26:46.161Z","updated_at":"2025-11-28T14:06:39.989Z","avatar_url":"https://github.com/commonphp.png","language":"PHP","readme":"# CommonPHP Event Management Library\n\nThe CommonPHP Event Management Library offers a powerful and flexible system to handle event-driven programming within PHP applications. It provides mechanisms for event registration, de-registration, triggering, and dynamic hook management.\n\n## Features\n\n- **Event Registration \u0026 Deregistration**: Easily register and deregister events within your application.\n- **Dynamic Hook Management**: Attach and manage callbacks (hooks) to events with support for priority ordering.\n- **Event Triggering**: Trigger events dynamically, executing all attached hooks in priority order.\n- **Exception Handling**: Robust exception handling for event-related operations, ensuring clear error reporting and resolution.\n- **Service Manager Integration**: Seamlessly integrates with the CommonPHP Service Management framework for dependency management.\n\n## Installation\n\nUse Composer to install the Event Management Library into your project:\n\n```bash\ncomposer require comphp/events\n```\n\n## Basic Usage\n\nTo get started with the CommonPHP Event Management Library, please refer to the example provided in the `examples/general-usage.php` file within the library. This example demonstrates how to set up the `EventManager`, register events, attach hooks with callbacks, and trigger events within your application.\n\nThe example covers essential functionalities such as event registration, hook management, and event triggering, showcasing the library's integration with the CommonPHP Service Management framework for comprehensive event-driven programming.\n\n```php\n// Sample snippet from examples/general-usage.php\n\nrequire '../vendor/autoload.php';\n\nuse CommonPHP\\Events\\EventManager;\nuse CommonPHP\\Events\\ServiceProviders\\EventManagerServiceProvider;\nuse CommonPHP\\ServiceManagement\\ServiceManager;\n\n// Simulating the ServiceManager setup\n$serviceManager = new ServiceManager();\n$serviceManager-\u003eproviders-\u003eregisterProvider(EventManagerServiceProvider::class);\n\n// Setting up the EventManager and registering it with the ServiceManager\n$eventManager = $serviceManager-\u003eget(EventManager::class);\n\n// Example usage of EventManager within a DemoClass\nclass DemoClass {\n    // Implementation details...\n}\n\n// For full example, please refer to examples/general-usage.php\n```\n\nFor a complete and runnable example, including event deregistration and exception handling, please refer to the provided file. This will give you a practical understanding of how to integrate and utilize the event management capabilities in your projects.\n\n## Advanced Usage\n\nThe library also supports advanced features like event de-registration, priority-based hook execution, and exception handling for robust event management. For more detailed examples, refer to the `/examples` directory.\n\n## Contributing\n\nContributions to the CommonPHP Event Management Library are welcome. Please refer to the contributing guidelines for more information on how to submit pull requests, report issues, or request features.\n\n## License\n\nThis library is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommonphp%2Fevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommonphp%2Fevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommonphp%2Fevents/lists"}