PHP code example of 1eonardo-dev / monitoring-client-legacy
1. Go to this page and download the library: Download 1eonardo-dev/monitoring-client-legacy 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/ */
1eonardo-dev / monitoring-client-legacy example snippets
use LeonardoDev\Monitoring\Legacy\MonitoringClient;
$monitoring = new MonitoringClient(
'https://monitoring.your-company.com',
'mp_...',
'php',
'1.0.0'
);
try {
// your code
} catch (Exception $e) {
$monitoring->captureException($e);
}
$monitoring->captureMessage('Something weird happened', 'warning');
use LeonardoDev\Monitoring\Legacy\Config;
use LeonardoDev\Monitoring\Legacy\Event;
use LeonardoDev\Monitoring\Legacy\MonitoringClient;
$client = MonitoringClient::fromConfig(new Config(
'https://monitoring.your-company.com',
'mp_...',
'php',
'1.0.0'
));
$client->captureEvent(new Event('custom', 'warning', 'something happened'));
use LeonardoDev\Monitoring\Legacy\MonitoringClient;
use LeonardoDev\Monitoring\Legacy\Transport\Transport;
class MyTransport implements Transport
{
public function send($url, $body, array $headers)
{
// ... return array('status' => int, 'body' => string), or null on failure.
}
}
$client = new MonitoringClient(
'https://monitoring.your-company.com',
'mp_...',
'php',
null,
2,
'/api/v1/events',
new MyTransport()
);
bash
php tests/run.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.