Events - 10quality/license-keys-php-client GitHub Wiki
The client supports the ability to specify event handlers that will allow for logging or other customization.
Usage
Specify event handler callables using the on()
chainable method after instantiating the Client
, like this:
$response = Api::activate(
Client::instance()
->on('start', function($startMicrotime) {
// Sample function log
log($startMicrotime);
})
->on('finish', function($finisMicrotime) {
// Sample function log
log($finisMicrotime);
}),
function() use($licenseKey) {
// Code here...
},
function($licenseString) {
// Code here...
}
);
Events
Key String | Parameters | Description |
---|---|---|
start |
string $microtime |
Triggered before an endpoint request is sent, before everything is initialized. |
finish |
string $finishMicrotime, string $startMicrotime |
Triggered after an endpoint has responded. |
endpoint |
string $endpoint, string $url |
Triggered after the API has indentified the endpoint to use and has built the request url. |
request |
mixed $request |
Triggered before the request is sent. Gives request data as parameter. |
response |
mixed $response |
Triggered before a response has been received. Gives raw response data as parameter. |
headers |
array $headers |
Triggered before headers have been parsed and set. Returns HTTP ready headers. |