PHP / Laravel
The TraceStax PHP SDK supports Laravel Queues and Symfony Messenger. A single package handles both.
Requirements
Section titled “Requirements”- PHP 8.1+
- Laravel 10.x / 11.x, or Symfony 6.x / 7.x
Installation
Section titled “Installation”composer require tracestax/tracestax-phpThe package auto-discovers itself via Laravel’s package discovery. Add your API key to .env:
TRACESTAX_API_KEY=ts_live_xxxxxxxxxxxxThen publish the config (optional):
php artisan vendor:publish --tag=tracestax-configThe SDK registers a JobProcessing, JobProcessed, and JobFailed listener automatically. No changes to your job classes are needed.
Queue Worker:
php artisan queue:work --queue=default,highEvents flow as soon as the worker starts.
Register the middleware in your messenger config:
framework: messenger: buses: messenger.bus.default: middleware: - TraceStax\Symfony\TraceStaxMiddlewareConfigure via environment variable or explicitly:
tracestax: api_key: '%env(TRACESTAX_API_KEY)%'For any PHP application without a framework:
use TraceStax\Client;
$client = new Client(['api_key' => getenv('TRACESTAX_API_KEY')]);
// Wrap your job execution$event = $client->startJob('process-order', 'default');try { processOrder($orderId); $event->succeed();} catch (Throwable $e) { $event->fail($e->getMessage()); throw $e;}Configuration
Section titled “Configuration”| Option | Env var | Default | Description |
|---|---|---|---|
api_key | TRACESTAX_API_KEY | — | Required |
worker_id | TRACESTAX_WORKER_ID | hostname + PID | Worker identifier |
enabled | TRACESTAX_ENABLED | true | Set to false in tests |
ingest_url | TRACESTAX_INGEST_URL | https://ingest.tracestax.com | Custom endpoint |
timeout | — | 3 | HTTP timeout in seconds |
Testing
Section titled “Testing”TRACESTAX_ENABLED=falseOr in a test service provider:
Config::set('tracestax.enabled', false);Troubleshooting
Section titled “Troubleshooting”Events not appearing (Laravel)
Confirm the queue worker process has TRACESTAX_API_KEY in its environment. If you’re using Laravel Horizon, add it to the horizon process env in your supervisor config, not just the web .env.