The TrustPort Beacon Laravel SDK (trustportidentity/beacon-laravel) auto-registers via Laravel package discovery. With only an API key it traces HTTP requests (with the signed-in user, including Sanctum), database queries, queue jobs, cache and logs, and captures exceptions and PHP fatal errors. Migrating from Laravel Nightwatch takes five minutes.
The service provider and Beacon facade are auto-discovered β no manual registration needed:
composer require trustportidentity/beacon-laravel:^1.2Add these to your .env file:
BEACON_INGEST_URL=https://beacon-api.trustportidentity.com
BEACON_API_KEY=tb_live_your_tenant_key
BEACON_SERVICE_NAME=billing-api
BEACON_ENVIRONMENT=production # label in Beacon: production / staging / local
BEACON_SAMPLE_RATE=1 # 0-1; errors are always sentNothing to do: the package adds BeaconMiddleware to the global stack itself once BEACON_API_KEY is set. Health checks (up, health, api/health) are skipped; change with BEACON_IGNORE_PATHS. Only if you set BEACON_AUTO_MIDDLEWARE=false do you register it yourself:
use TrustPortIdentity\Beacon\BeaconMiddleware;
protected $middleware = [
BeaconMiddleware::class,
// ...your other global middleware
];use TrustPortIdentity\Beacon\Beacon;
class InvoiceController extends Controller
{
public function index()
{
$span = Beacon::span('db.mysql.select_invoices', 'database');
$invoices = Invoice::where('status', 'pending')->get();
$span->setTag('rows', $invoices->count())->end();
Beacon::identify(['id' => auth()->id(), 'email' => auth()->user()?->email]);
return response()->json($invoices);
}
}Wrap a job's handle() body in a Beacon::span(..., 'job') to track queue processing time and failures the same way HTTP requests are tracked.
Every request is already batched (BEACON_BATCH_SIZE) instead of one network call per request. On top of that, set BEACON_SAMPLE_RATE (0.0β1.0, default 1.0) to trace only a fraction of requests in high-traffic services β this is what actually keeps you inside your plan's monthly quota. Exceptions are always sent regardless of sampling.
BEACON_SAMPLE_RATE=0.2 # trace ~20% of requests| Situation | Shown in Beacon as |
|---|---|
| Exception in a web request (incl. ones Laravel turns into a 500) | The request trace with user, route and stack trace |
| Exception in a queue job | A QUEUE trace with the failure |
| Exception in artisan / scheduler code | A CLI trace |
| PHP fatals: memory exhausted, max execution time, parse errors | A FatalError trace (sent from a shutdown handler) |
| 404, validation and auth exceptions Laravel does not report | Not sent (no noise) |
Opt out with BEACON_CAPTURE_EXCEPTIONS=false or BEACON_CAPTURE_FATALS=false.
No setting needed. The Authorization, Cookie, Set-Cookie, X-Api-Key and CSRF headers are replaced with [redacted], and so is the value of any query parameter that looks like a secret (token, secret, password, auth, signature, session, key, cron_key, api_key). Beacon's server scrubs the same names again on ingest. BEACON_SANITIZE_PII=true also removes card-number-like values.
php artisan nightwatch:agent (Beacon has no agent process; remove its supervisor program).composer remove laravel/nightwatch, then install Beacon as above.NIGHTWATCH_TOKEN / NIGHTWATCH_REQUEST_SAMPLE_RATE with BEACON_API_KEY / BEACON_SAMPLE_RATE.php artisan config:clear and php artisan queue:restart.BEACON_SAMPLE_RATE is below 1, or the path is in BEACON_IGNORE_PATHS (supports *, e.g. api/send_*_mails for cron pings).BEACON_API_KEY unset, config cached (php artisan config:clear), or the server cannot reach BEACON_INGEST_URL.Beacon::identify([...]).php artisan queue:restart.Our engineers can help tune the batching interval for long-running workers.