1. Go to this page and download the library: Download log-engine/logengine-php 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/ */
log-engine / logengine-php example snippets
use Inspector\Inspector;
use Inspector\Configuration;
$configuration = new Configuration('YOUR_INGESTION_KEY');
$inspector = new Inspector($configuration);
// Start an execution cycle with a transaction
$inspector->startTransaction($_SERVER['PATH_INFO']);
$result = $inspector->addSegment(function ($segment) {
// Do something here...
return "Hello World!";
}, 'my-process');
echo $result; // this will print "Hello World!"
class CustomTransport implements \Inspector\Transports\TransportInterface
{
protected $configuration;
protected $queue = [];
public function __constructor($configuration)
{
$this->configuration = $configuration;
}
public function addEntry(\Inspector\Models\Arrayable $entry)
{
// Add an \Inspector\Models\Arrayable entry in the queue.
$this->queue[] = $entry;
}
public function flush()
{
// Performs data transfer.
$handle = curl_init('https://ingest.inspector.dev');
curl_setopt($handle, CURLOPT_POST, 1);
curl_setopt($handle, CURLOPT_HTTPHEADER, [
'X-Inspector-Key: xxxxxxxxxxxx',
'Content-Type: application/json',
'Accept: application/json',
]);
curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($this->queue));
curl_exec($handle);
curl_close($handle);
}
}
$inspector->setTransport(function ($configuration) {
return new CustomTransport($configuration);
});
shell
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.