spatie/laravel-flare
Send Laravel 11+ (PHP 8.2+) exceptions and logs to Flare for production error tracking, alerts, and sharing. Configure with your Flare API key to automatically report issues and get notified when they occur.
Installation:
composer require spatie/laravel-flare
Publish the config file:
php artisan vendor:publish --provider="Spatie\FlareProvider\FlareServiceProvider" --tag="flare-config"
Configuration:
.env:
FLARE_API_KEY=your_api_key_here
FLARE_ENABLED=true in .env (default is false in production).First Use Case:
1/0 in Tinker or a route) and verify it appears in your Flare dashboard.Error Capture:
App\Exceptions\Handler (report() method).Custom Data Injection:
Flare::capture() or Flare::captureException():
try {
// Risky operation
} catch (\Exception $e) {
Flare::captureException($e, [
'user_id' => auth()->id(),
'custom_metric' => 'value',
]);
}
Environment-Specific Behavior:
local or testing environments via flare.php:
'enabled' => env('FLARE_ENABLED', false),
'except' => [
'local',
'testing',
],
Middleware Integration:
HandleFlare middleware to conditionally enable/disable Flare:
public function handle($request, Closure $next) {
if ($request->ip() === '123.123.123.123') {
config(['flare.enabled' => false]);
}
return $next($request);
}
Queueing Errors:
php artisan queue:work --daemon
Testing:
report() in Handler:
public function report(Throwable $exception) {
if (app()->environment('testing')) {
return; // Skip Flare in tests
}
parent::report($exception);
}
404, 405) are now grouped under errors::{status_code} in Flare.
404 error will appear under errors:404 in the dashboard.API Key Leaks:
.env to version control. Use environment variables or a secrets manager..env to .gitignore and run php artisan config:clear after deploying.Queue Delays:
php artisan queue:work).php artisan queue:failed-table for failed jobs.Sensitive Data Exposure:
flare.php:
'ignored_request_data' => [
'password',
'credit_card',
],
Livewire v4 Stack Traces:
Performance Impact:
Log Level:
config/logging.php:
'channels' => [
'flare' => [
'driver' => 'single',
'path' => storage_path('logs/flare.log'),
'level' => 'debug',
],
],
storage/logs/flare.log for transmission issues.Network Issues:
curl -X POST https://flareapp.io/api/v1/errors -H "Authorization: Bearer YOUR_KEY"
Route Error Grouping:
flare.php config hasn’t disabled grouping.Custom Error Data:
Flare::extend(function ($payload) {
$payload['app_version'] = config('app.version');
return $payload;
});
Webhook Notifications:
flare.php.Ignition Integration:
spatie/laravel-ignition for local dev:
// In Handler.php
if (app()->environment('local')) {
return false; // Skip Flare locally
}
Rate Limiting:
AppServiceProvider:
use Illuminate\Support\Facades\RateLimiter;
RateLimiter::for('flare', function () {
return Limit::perMinute(100)->by($this->app['request']->ip());
});
Livewire-Specific Debugging:
Flare::capture() in handleError() methods of Livewire components for granular context.How can I help you explore Laravel packages today?