SDKs
PHP SDK Guide
PHP 8.1+ SDK with zero runtime dependencies (requires ext-curl), Laravel exception handler binding, and worker flush hooks.
The Lazers PHP SDK (`oneverse/lazers`) targets PHP 8.1+ environments. Because PHP scripts are commonly request-scoped, `captureError()` performs an immediate, best-effort dispatch while buffering in-process failures.
Installation ```bash composer require oneverse/lazers ```
Integration Code Examples
Plain PHP
<?php
use Lazers\Client;
$client = new Client([
'api_key' => getenv('LAZERS_API_KEY'),
'endpoint' => getenv('LAZERS_ENDPOINT') ?: 'https://api.lazers.app',
'project_id' => getenv('LAZERS_PROJECT_ID'),
'environment' => getenv('LAZERS_ENVIRONMENT') ?: 'production',
'service_name' => 'billing-api',
'release' => getenv('APP_COMMIT_SHA'),
]);
try {
processPayment();
} catch (\Throwable $e) {
$client->captureError($e, [
'actor' => ['type' => 'customer', 'id' => 'cust_1048'],
'correlation_id' => 'inv_89432'
]);
} finally {
$client->flush();
}Laravel ServiceProvider & Exception Handler
// app/Providers/LazersServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Lazers\Client;
class LazersServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(Client::class, function () {
return new Client([
'api_key' => config('services.lazers.key'),
'endpoint' => config('services.lazers.endpoint', 'https://api.lazers.app'),
'project_id' => config('services.lazers.project_id'),
'environment' => config('app.env'),
'service_name' => 'laravel-app',
'release' => config('app.version'),
]);
});
}
}
// In app/Exceptions/Handler.php:
public function register()
{
$this->reportable(function (\Throwable $e) {
if ($this->shouldReport($e)) {
app(Client::class)->captureError($e, [
'actor' => auth()->check() ? ['type' => 'user', 'id' => (string) auth()->id()] : null
]);
}
});
}