Install the Daemon Add the package via Composer:
composer require spatie/flare-daemon
Or use the PHAR for standalone execution:
wget https://github.com/spatie/flare-daemon/releases/latest/download/daemon.phar
chmod +x daemon.phar
Start the Daemon
Run the daemon locally (default: 127.0.0.1:8787):
php vendor/bin/flare-daemon
Or via PHAR:
./daemon.phar
Configure Your Flare Client Update your Laravel/Flare client to use the daemon for async delivery:
use Spatie\FlareClient\Flare;
Flare::useDaemon(); // Enables daemon transport
Verify Integration Trigger an error or log in your app. Check the daemon logs for buffered payloads:
php vendor/bin/flare-daemon --verbose
.env or runtime):
Flare::useDaemon('http://127.0.0.1:8787');
/status endpoint or logs to confirm delivery.Client-Side Setup
AppServiceProvider or config:
Flare::useDaemon(); // Uses default local address (127.0.0.1:8787)
Flare::useDaemon('http://flare-daemon:8787');
Daemon Configuration
.env):
FLARE_DAEMON_LISTEN=0.0.0.0:8787 # Bind to all interfaces for Docker
FLARE_DAEMON_BUFFER_BYTES=524288 # Increase buffer size for high-volume apps
FLARE_DAEMON_FLUSH_AFTER_SECONDS=5 # Flush more frequently
Payload Routing
{
"api_key": "your-key-here",
"type": "error",
"payload": { ... }
}
Testing Locally
--test flag to bypass upstream delivery (for debugging):
php vendor/bin/flare-daemon --test
curl:
curl -X POST http://127.0.0.1:8787/v1/errors \
-H "Content-Type: application/json" \
-d '{"api_key":"test","payload":{"message":"Test error"}}'
Health Checks
/health (returns 200 if running)./status (returns buffered payload counts).# docker-compose.yml
services:
app:
build: .
flare-daemon:
image: ghcr.io/spatie/flare-daemon
ports:
- "8787:8787"
environment:
- FLARE_DAEMON_LISTEN=0.0.0.0:8787
Flare::useDaemon('http://flare-daemon:8787');
SIGINT/SIGTERM to drain buffers before exiting.429 (Too Many Requests) and 403 (Forbidden) responses./status endpoint.// In a service provider
$daemonConfig = [
'buffer_bytes' => 1048576, // 1MB
'flush_after_seconds' => 30,
];
// Pass config to the daemon (if supported in future versions)
--verbose for debugging:
php vendor/bin/flare-daemon --verbose
Flare::useDaemon()->setLogger(app('log')->channel('flare'));
Buffer Overflows
FLARE_DAEMON_BUFFER_BYTES.BufferExceeded warnings.Network Timeouts
FLARE_DAEMON_UPSTREAM_TIMEOUT_SECONDS) may block the daemon.API Key Leaks
env() helper:
Flare::useDaemon()->setApiKey(env('FLARE_API_KEY'));
Daemon Not Running
Flare::useDaemon()->fallbackToDirectDelivery();
Composer Lock Watcher
composer.lock changes (default behavior).FLARE_COMPOSER_LOCK="" if not needed.Check Buffer Status
/status to see pending payloads:
curl http://127.0.0.1:8787/status
{
"buffers": {
"api_key_123": {
"errors": 5,
"traces": 0,
"logs": 2
}
}
}
Enable Verbose Logging
--verbose to see real-time payload processing:
php vendor/bin/flare-daemon --verbose
[DEBUG] Buffered error for api_key_123 (size: 1.2KB)
[DEBUG] Flushed 3 errors to Flare
Test Payloads Directly
tests/test.sh script to simulate payloads:
bash tests/test.sh YOUR_API_KEY
curl:
curl -X POST http://127.0.0.1:8787/v1/errors \
-H "Content-Type: application/json" \
-d '{"api_key":"test","payload":{"message":"Debug test"}}'
Inspect Upstream Failures
429/403 responses in logs. The daemon auto-pauses ingestion for affected keys.//
How can I help you explore Laravel packages today?