facade/flare-client-php
PHP client for Flare error reporting, powering Ignition in Laravel. Captures and sends exceptions, logs, and context to Flare with Laravel integration, middleware, and configurable transport—helping you debug production issues faster.
composer require facade/flare-client-php
php artisan vendor:publish --provider="Facade\FlareClient\FlareServiceProvider" --tag="config"
.env with your Flare API key:
FLARE_API_KEY=your_api_key_here
use Facade\FlareClient\Flare;
try {
// Risky operation
} catch (\Exception $e) {
Flare::report($e); // Send to Flare
throw $e; // Re-throw or handle locally
}
FlareServiceProvider (handles auto-registration in Laravel).Flare (primary entry point for reporting).config/flare.php (API key, endpoint, environment filtering).Flare::report(new \Exception("Oops!"));
Flare::report($e)
->context([
'user_id' => auth()->id(),
'request_data' => request()->all(),
]);
Add contextual events leading to an error:
Flare::breadcrumb('User clicked "Submit"');
Flare::breadcrumb('Processing order #123', [
'order_id' => 123,
'status' => 'pending',
]);
Automatically report uncaught exceptions in Laravel:
use Facade\FlareClient\Flare;
class ReportExceptions
{
public function handle($request, Closure $next)
{
try {
return $next($request);
} catch (\Exception $e) {
Flare::report($e);
throw $e;
}
}
}
Attach logs to errors for deeper context:
Flare::report($e)
->withLogs([
'query' => 'SELECT * FROM users WHERE id = 1',
'result' => $users,
]);
Disable reporting in local environments via config:
'environments' => ['production', 'staging'],
Flare::report($e)->later(); // Uses Laravel's queue
Flare::report($e)->context(['feature_flags' => ['new_ui' => true]]);
API Key Leaks:
.env or hardcode keys in version control.env() helper or config files for keys.Sensitive Data in Context:
context() or withLogs().Flare::report($e)->mask() to redact sensitive fields:
Flare::report($e)->mask(['password', 'credit_card']);
Performance Overhead:
->later() for production.local environments to avoid noise.Environment Mismatches:
FLARE_ENVIRONMENT in .env matches your Flare dashboard setup.production if unset.Breadcrumb Limits:
config/flare.php for correct API key/endpoint.https://flareapp.io/api/v1/errors for failures.APP_DEBUG=true to see if exceptions are caught before Flare.Custom Transport: Override the HTTP client for proxy support or retries:
Flare::setTransport(new CustomHttpClient());
Event Listeners:
Hook into flare.reporting event to modify payloads:
Flare::extend(function ($payload) {
$payload['custom_field'] = 'value';
return $payload;
});
Queue Failures:
Handle failed queue jobs for ->later() reports:
Flare::report($e)->later()->onFailure(function ($job, $exception) {
Log::error("Flare report failed: " . $exception->getMessage());
});
'endpoint' => 'https://your-custom-flare-endpoint/api/v1/errors',
'verify_ssl' => false,
How can I help you explore Laravel packages today?