spo / sdk-php
SPO PHP SDK for Symfony and Doctrine telemetry
v0.1.0
2026-09-04 11:55 UTC
Requires
- php: >=8.2
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A lightweight Composer package for Symfony and Doctrine applications to send backend telemetry to SPO.
Install
composer require spo/sdk-php
Quick start
<?php use Spo\Sdk\Config; use Spo\Sdk\SpoClient; $config = new Config( apiKey: $_ENV['SPO_API_KEY'], service: 'billing-api', environment: 'production', release: '2026.08.29', endpoint: 'https://ingest.spo.dev', sampleRate: 1.0, ); $spo = new SpoClient($config); $traceId = $spo->startRequest([ 'route' => '/orders/42', 'method' => 'GET', ]); try { // application logic $spo->captureQuery([ 'sql' => 'SELECT * FROM orders WHERE id = ?', 'durationMs' => 42, 'traceId' => $traceId, ]); } catch (\Throwable $e) { $spo->captureError($e, ['traceId' => $traceId]); } finally { $spo->finishRequest($traceId, [ 'route' => '/orders/42', 'method' => 'GET', 'statusCode' => 200, 'durationMs' => 118, ]); }
What it captures
- incoming request metadata
- route method and duration
- Doctrine query SQL timing
- uncaught or handled exceptions
- outbound dependency timing
- trace ID correlation
- environment and release metadata
Safety
- sanitizes SQL before sending
- redacts configured sensitive fields
- safe failure if SPO is unreachable
- batching avoids request-blocking overhead
Symfony integration ideas
- request listener for trace start/finish
- exception listener for error capture
- Doctrine DBAL query listener for SQL timing
OTEL compatibility
This SDK is the direct integration route. The SPO ingestion API also supports OTEL-compatible telemetry ingestion through the standardized event contract described in the SPO OTEL contract document.