g4 / events
events php library
Installs: 42 426
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 9
Forks: 0
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-10-26 16:33:36 UTC
README
events - php library
Install
Via Composer
composer require g4/events
Usage
// Register event as an anonymous function \G4\Events\PubSub::on('event_name', function($arg1, $arg2) { echo $arg1; echo $arg2; }); // Register event as a class method \G4\Events\PubSub::on('event_name', [new \G4\Events\Test(), 'test']); // Unregister all subscribers \G4\Events\PubSub::clear(); // Unregister all subscribers based on event name \G4\Events\PubSub::off('event_name'); // Unregister one single subscriber \G4\Events\PubSub::off('event_name', [new \G4\Events\Test(), 'test']); // Get all events and subscribers \G4\Events\PubSub::getEvents(); // Check if event is registered \G4\Events\PubSub::has('event_name'); // Check if subscriber is registered \G4\Events\PubSub::has('event_name', [new \G4\Events\Test(), 'test']); // Trigger event with arguments \G4\Events\PubSub::trigger('event_name', [12345, 987]); // Trigger event without arguments \G4\Events\PubSub::trigger('event_name');
Development
Install dependencies
$ make install
Run tests
$ make test
License
(The MIT License) see LICENSE file for details...