Releases: commonphp/events
Release 0.1 (Alpha)
We're thrilled to announce the release of the CommonPHP Event Management Library version 0.1! This initial release lays the foundation for a robust and flexible event-handling system within PHP applications. Designed with ease of use and extendability in mind, our library offers a streamlined approach to managing event-driven programming patterns.
Highlights of v0.1:
- Event Registration & Deregistration: Easily define and remove events within your application.
- Dynamic Hook Management: Attach callbacks (hooks) to events with ease, with support for prioritizing execution order.
- Seamless Event Triggering: Trigger events anywhere in your application, executing all attached hooks in a controlled manner.
- Integrated Exception Handling: Benefit from comprehensive exception handling, making debugging and error resolution straightforward.
- Service Manager Compatibility: Fully compatible with the CommonPHP Service Management framework, allowing for dependency-injected event handling.
Basic Usage:
To get a quick start, we've included an example file (examples/general-usage.php
) demonstrating the core functionalities such as event registration, hooking callbacks, and triggering events. Here's a peek:
require 'vendor/autoload.php';
use CommonPHP\Events\EventManager;
use CommonPHP\ServiceManagement\ServiceManager;
$serviceManager = new ServiceManager();
$eventManager = new EventManager();
$eventManager->bootstrap($serviceManager);
$event = $eventManager->register('myEvent');
$event->hook(function () { echo "Event triggered!\n"; });
$eventManager->trigger('myEvent');
For a full example, including advanced usage and integration with the Service Management framework, please refer to examples/general-usage.php
in the library.
Installation:
Install the library using Composer to dive into event-driven programming:
composer require commonphp/events
Contributing:
Your contributions are welcome! Whether it's submitting pull requests, reporting bugs, or suggesting new features, we look forward to your input to make this library even better.
License:
This library is open-sourced under the MIT license, promoting a permissive and inclusive environment for developers.