资 源 简 介
The php-events package provides an easy way to trigger events and listen to them without the need to extend any of your classes. This package does not follow the traditional Dispatcher/Observer type of architecture, which requires a number of your classes to extend potentially unwanted parents.
php-events allow you to just trigger an event and have none, one or more handlers listen and respond to them.
The package is very light (6 files, 166 non-comment LOC), well documented with many examples (508 comment LOC) and has an extensive bundled unit test suite (100% coverage). There is a php 5.3 (namespaced) and a php < 5.3 version available.
Triggering Events
Basic usage is really simple:
In your class, without extending or implementing anything unwanted, or implementing additional functionality, just create an event, and you"re halfway there:
class A {
public function someFunction($arg, ...){
new Event_Event("some-nam