Download the PHP package s1mpletru1h/events without Composer
On this page you can find all versions of the php package s1mpletru1h/events. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download s1mpletru1h/events
More information about s1mpletru1h/events
Files in s1mpletru1h/events
Package events
Short Description Events - the foundation of everything.
License MIT
Informations about the package events
EVENTS | The foundation of everything.
About Events
Events allow you to see everything that is happening in your application.
Events do this by allowing you to create synchronous, event-driven functional callback-response graphs in any application, by calling just two simple methods:
$events->pub($event_name)
and $events->sub($event_name, $callback)
Colorful logging allows you to see what is going on in your application through your choice of standard out, text file logs, and in the near future, in-memory and sql/no-sql data stores.
Simple:
An EVENT
is just an all-caps text string, with an optional colon separating the :LEVEL
which can be any of the following strings, ['VERBOSE', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
, and an arbitrary array ['of' => $data]
.
Events are published through the $events->pub('EVENT:LEVEL', ['arbitrary' => $data]);
function, and subscribed to with $events->sub('EVENT', function($event, $data) {...});
Testable:
You can see whether or not an event happened simply by calling $events->didOccur(['SOME', 'EVENTS'], $within_the_last_n_events);
This method will return true
if all of your events really did happen $within_the_last_n_events
, or false
otherwise.
Easy:
Every event can have unlimited callbacks bound to fire every time it is trigged. The only requirement is that the callback must take two arguments: the event name (a required string) and the event data (an optional array). Event subscriber callback return values are captured and pushed onto an array, and returned from the pub function in an array that preserves the order in which they were returned.
Fun:
Colorful logs make running your application fun to watch in standard out, log files per instance, or combined into a single master log file, or both (database event logging coming soon!).