1. Go to this page and download the library: Download mindscape/raygun4php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mindscape / raygun4php example snippets
namespace {
lient;
use Raygun4php\RaygunClient;
use Raygun4php\Transports\GuzzleAsync;
$httpClient = new Client([
'base_uri' => 'https://api.raygun.com',
'timeout' => 2.0,
'headers' => [
'X-ApiKey' => 'INSERT_API_KEY_HERE'
]
]);
$transport = new GuzzleAsync($httpClient);
$raygunClient = new RaygunClient($transport);
set_error_handler(function($errno, $errstr, $errfile, $errline) use ($raygunClient) {
$raygunClient->SendError($errno, $errstr, $errfile, $errline);
});
set_exception_handler(function($exception) use ($raygunClient) {
$raygunClient->SendException($exception);
});
register_shutdown_function(function() use ($raygunClient) {
$lastError = error_get_last();
if (!is_null($lastError)) {
[$type, $message, $file, $line] = $lastError;
$raygunClient->SendError($type, $message, $file, $line);
}
});
register_shutdown_function([$transport, 'wait']);
}
// Disable user tracking:
$raygunClient = new RaygunClient($transport, true);
$raygunClient->SetGroupingKey(function($payload, $stackTrace) {
// Inspect the above parameters and return a hash from the properties ...
return $payload->Details->Error->Message; // Naive message-based grouping only
});