Download the PHP package vaibhavpandeyvpz/soochak without Composer
On this page you can find all versions of the php package vaibhavpandeyvpz/soochak. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vaibhavpandeyvpz/soochak
More information about vaibhavpandeyvpz/soochak
Files in vaibhavpandeyvpz/soochak
Package soochak
Short Description A simple but useful events manager based on PSR-14 for PHP >= 8.2.
License MIT
Homepage https://github.com/vaibhavpandeyvpz/soochak
Informations about the package soochak
Soochak
Soochak (
सूचक) - A modern, PSR-14 compliant event dispatcher for PHP 8.2+
Soochak is a lightweight, high-performance event management library that implements the PSR-14 Event Dispatcher standard. It provides a simple yet powerful API for implementing the observer pattern in your PHP applications.
Features
- ✅ PSR-14 Compliant - Full implementation of EventDispatcherInterface and ListenerProviderInterface
- ✅ Backward Compatible - Legacy API maintained for existing codebases
- ✅ Priority Support - Control listener execution order with priority queues
- ✅ Event Propagation - Stop event propagation when needed
- ✅ Type Safe - Full PHP 8.2+ type hints and union types
- ✅ Memory Efficient - Uses generators for lazy listener iteration
- ✅ 100% Test Coverage - Comprehensive test suite with 50+ tests
- ✅ Zero Dependencies - Only requires PSR-14 interfaces
Requirements
- PHP 8.2 or higher
- Composer
Installation
Install via Composer:
Quick Start
Basic Usage
Using PSR-14 Standard API
Usage Examples
Priority-Based Listeners
Listeners with higher priority values are executed first:
Event Propagation Control
Stop further listeners from executing:
Working with Event Objects
Custom Event Objects
You can use any object as an event:
Managing Listeners
Getting Listeners for an Event
API Reference
EventManager
The main event manager class implementing PSR-14 interfaces.
Methods
attach(string|object $event, callable $callback, int $priority = 0): void- Attach a listener to an eventdetach(string|object $event, callable $callback): bool- Remove a specific listenerclear(string|object $event): void- Clear all listeners for an eventdispatch(object $event): object- Dispatch an event (PSR-14)getListenersForEvent(object $event): iterable- Get all listeners for an event (PSR-14)
Event
Minimal event implementation implementing StoppableEventInterface.
Methods
isPropagationStopped(): bool- Check if propagation is stoppedstopPropagation(bool $flag = true): void- Stop event propagation
PSR-14 Compliance
Soochak fully implements the PSR-14 Event Dispatcher standard:
- ✅
Psr\EventDispatcher\EventDispatcherInterface - ✅
Psr\EventDispatcher\ListenerProviderInterface - ✅
Psr\EventDispatcher\StoppableEventInterface(via Event class)
You can use Soochak with any PSR-14 compatible library or framework.
Testing
The project includes a comprehensive test suite with 100% code coverage:
Performance
Soochak is designed for performance:
- Lazy Evaluation - Uses generators to avoid loading all listeners into memory
- Direct Callbacks - Uses direct function calls instead of
call_user_func() - Efficient Queues - Priority queues with FIFO ordering for same-priority listeners
- Minimal Overhead - Zero dependencies beyond PSR-14 interfaces
Architecture
Components
- EventManager - Main dispatcher implementing PSR-14 interfaces, manages listener registration and retrieval
- Event - Standard event implementation
- EventListenerQueue - Priority queue for listener ordering
Design Patterns
- Observer Pattern - Event/listener architecture
- Strategy Pattern - Pluggable listener providers
- Priority Queue - Efficient listener ordering
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Vaibhav Pandey
- Email: [email protected]
- Homepage: https://github.com/vaibhavpandeyvpz/soochak
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Changelog
Version 2.0.0 (Current)
- ✅ Upgraded to PHP 8.2+
- ✅ Full PSR-14 compliance
- ✅ Modern type hints and union types
- ✅ 100% test coverage
- ✅ Performance optimizations
- ✅ Comprehensive documentation
Version 1.0.0 (Legacy)
- Initial release with PHP 5.3+ support
- Basic event management functionality
Soochak - Simple, powerful, and standards-compliant event management for PHP.