Integrations
Laravel SDK
Two packages: beacon-status/beacon-php, a dependency-free PHP 8.2+ client for the whole REST API, incident ingest, heartbeats and webhook verification; and beacon-status/laravel, which adds a facade, config, a heartbeat command, a scheduler macro and webhook middleware for Laravel 11–13.
Not yet published to Packagist — install from GitHub for now.
Add both repositories to your composer.json as vcs repositories, as shown below.
Installation
// composer.json
"repositories": [
{ "type": "vcs", "url": "https://github.com/shaferllc/beacon-php" },
{ "type": "vcs", "url": "https://github.com/shaferllc/beacon-laravel" }
],
"require": {
"beacon-status/beacon-php": "^1.0",
"beacon-status/laravel": "^1.0"
}
composer update beacon-status/beacon-php beacon-status/laravel
If you have a local clone instead, use { "type": "path", "url": "../beacon-laravel" } entries. Once the packages are on Packagist, drop the repositories block. The service provider and the Beacon facade are auto-discovered.
Configuration
BEACON_API_TOKEN=bchk_your_token
BEACON_URL=https://usebeacon.pro
BEACON_PAGE_SLUG=your-page-slug
BEACON_WEBHOOK_SECRET=your-webhook-signing-secret
Publish config/beacon.php to change the timeout or webhook tolerance:
php artisan vendor:publish --tag=beacon-config
Incidents and component status
use Beacon\Laravel\Facades\Beacon;
$incident = Beacon::createIncident([
'title' => 'Payment processing delays',
'impact' => 'major',
'state' => 'investigating',
'message' => 'Stripe webhook delivery is delayed.',
]);
Beacon::addIncidentUpdate($incident['id'], 'Fix deployed, monitoring.');
Beacon::resolveIncident($incident['id'], 'Webhook delivery restored.');
Beacon::updateComponent(12, ['status' => 'degraded_performance']);
REST resources
statusPages(), components(), monitors(), incidents(), maintenances(), subscribers(), webhooks() and imports() expose list, iterate, get, create, update and delete. Page-scoped resources take the page slug first; iterate() is a generator that follows the cursor.
Beacon::monitors()->create('acme', [
'name' => 'Postgres',
'type' => 'tcp',
'host' => 'db.example.com',
'port' => 5432,
'check_window_start' => '08:00',
'check_window_end' => '20:00',
]);
foreach (Beacon::incidents()->iterate('acme', ['state' => 'open']) as $incident) {
// …
}
Scheduler heartbeats
// routes/console.php
use Illuminate\Support\Facades\Schedule;
Schedule::command('backup:run')->daily()->pingBeacon('YOUR-HEARTBEAT-TOKEN');
The ping is sent only when the task succeeds, and a failed ping never breaks the schedule. From cron or a deploy script:
php artisan beacon:heartbeat YOUR-HEARTBEAT-TOKEN
Receiving webhooks
Route::post('/beacon/webhook', BeaconWebhookController::class)
->middleware('beacon.webhook')
->withoutMiddleware(\Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class);
The middleware checks X-Beacon-Signature against BEACON_WEBHOOK_SECRET with a constant-time comparison and rejects stale timestamps with a 403. Webhook format
Error handling
use Beacon\BeaconException;
try {
Beacon::components()->create('acme', ['name' => '']);
} catch (BeaconException $e) {
$e->status; // 422
$e->errorCode; // validation_failed, rate_limited, plan_limit_reached, …
$e->errors; // ['name' => ['…']]
$e->retryAfter; // seconds, on 429
}
Without Laravel
use Beacon\Beacon;
use Beacon\Webhook;
$beacon = new Beacon(getenv('BEACON_API_TOKEN'), pageSlug: 'acme');
$beacon->createIncident(['title' => 'Payments down', 'impact' => 'major']);
Beacon::ping('YOUR-HEARTBEAT-TOKEN');
$ok = Webhook::verify(file_get_contents('php://input'), getallheaders(), getenv('BEACON_WEBHOOK_SECRET'));
Testing
Bind your own Beacon\Transport\Transport in the container to record requests instead of sending them.