Introduction
Flare collects errors and exceptions thrown in your Laravel application and ships them to flareapp.io, together with everything we know about the moment they happened.
If you haven't installed the client yet, start with the installation guide.
How errors get to Flare
The Laravel client hooks into Laravel's exception handler automatically, so most of the time you don't need to do anything. Any unhandled exception is reported to Flare for you.
Registering manually
If you have customised Laravel's exception handling and want to make sure Flare receives reports, register it explicitly in bootstrap/app.php:
use Spatie\LaravelFlare\Facades\Flare;
->withExceptions(function (Exceptions $exceptions) {
Flare::handles($exceptions);
})
Flare::handles() wires Flare into Laravel's Exceptions configuration so every reportable throwable is also sent to Flare.
Reporting manually
When you catch a throwable yourself, use Laravel's report() helper:
try {
// ...
} catch (Throwable $exception) {
report($exception);
}
Errors reported this way are marked as handled in Flare, so you can filter them out separately from unhandled crashes.
PHP errors
PHP defines two kinds of things that can go wrong: exceptions, and errors (notices, warnings, fatal errors, and so on). The Flare client wraps PHP errors into ErrorException instances and reports them the same way as exceptions.
By default, every error level is sent to Flare. You can narrow that down through the report_error_levels key in config/flare.php:
'report_error_levels' => E_ALL & ~E_NOTICE,
Set the value to null to send every error level. Throughout the documentation, the word "error" covers both exceptions and PHP errors.
Data collection with errors
Each error report carries a lot of contextual data on top of the stacktrace (the request, the route, queries that ran during the request, recent logs, the authenticated user, and more). Most of it is collected for you, and you can extend or strip it where needed. The data collection section covers every collector in detail. A few that are especially useful around errors:
- Custom context. Attach key/value data that applies to every error and log.
- Laravel context. Anything stored via Laravel's
Contextfacade is automatically attached. - Exception context. Attach context to a specific exception class.
- Identifying users. Attach the authenticated user to a report.
- On this page
- How errors get to Flare
- Data collection with errors