Download the PHP package purpleharmonie/event-system without Composer
On this page you can find all versions of the php package purpleharmonie/event-system. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download purpleharmonie/event-system
More information about purpleharmonie/event-system
Files in purpleharmonie/event-system
Package event-system
Short Description Purpleharmonie Event System is a flexible and powerful event dispatching library for PHP applications. It provides a robust implementation of the PSR-14 Event Dispatcher standard, along with additional features for advanced use cases.
License MIT
Informations about the package event-system
Purpleharmonie Event System
Table of Contents
- Introduction
- Features
- Installation
- Basic Usage
- Advanced Concepts
- Event Subscribers
- Prioritized Listeners
- Stoppable Events
- Event Validation
- Middleware
- Conditional Event Dispatching
- Asynchronous Event Handling
- Integration with Dependency Injection
- Best Practices
- API Reference
Introduction
Purpleharmonie Event System is a flexible and powerful event dispatching library for PHP applications. It provides a robust implementation of the PSR-14 Event Dispatcher standard, along with additional features for advanced use cases.
Features
- PSR-14 compliant event dispatcher
- Support for event subscribers
- Prioritized event listeners
- Stoppable events
- Event validation
- Middleware support
- Conditional event dispatching
- Asynchronous event handling (hook)
- PSR-3 Logger integration
- Easy integration with dependency injection containers
Installation
You can install the Purpleharmonie Event System using Composer:
Basic Usage
Here's a simple example of how to use the event system:
Advanced Concepts
Event Subscribers
Event subscribers allow you to group multiple event listeners in a single class:
Prioritized Listeners
You can set priorities for listeners to control their execution order:
Stoppable Events
Stoppable events allow you to prevent further event propagation:
Event Validation
You can implement the ValidatableEventInterface
to add custom validation logic to your events:
Middleware
Middleware allows you to intercept and modify events before they reach the listeners:
Conditional Event Dispatching
The ConditionalEventDispatcher
allows you to add conditions for event dispatching:
Asynchronous Event Handling
You can implement the AsyncEventDispatcherInterface
to handle events asynchronously:
Integration with Dependency Injection
Here's an example of how to integrate the event system with a dependency injection container:
Best Practices
- Keep events small and focused on a single aspect of your application.
- Use event subscribers for organizing related listeners.
- Utilize priorities to ensure proper execution order of listeners.
- Implement validation for critical events to ensure data integrity.
- Use middleware for cross-cutting concerns that apply to multiple events.
- Consider using asynchronous event handling for time-consuming operations.
API Reference
For a complete API reference, please generate API documentation using a tool like phpDocumentor.