Flare by Spatie
    • Error Tracking
    • Performance Monitoring
    • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
  • Back to Flare ⌘↵ Shortcut: Command or Control Enter
  • Sign in
  • Try Flare for free
  • Error Tracking
  • Performance Monitoring
  • Logs Coming soon
  • Pricing
  • Docs
  • Insights
  • Changelog
    • Back to Flare ⌘↵ Shortcut: Command or Control Enter
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript React React Vue Vue Protocol Protocol
  • General
  • Installation
  • Integrating into a framework
  • Attribute providers
  • Application lifecycle
  • Censoring collected data
  • Ignoring collected data
  • Flare daemon
  • Errors
  • Introduction
  • Customise error report
  • Customising error grouping
  • Linking to errors
  • Logs
  • Introduction
  • Levels
  • With errors
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and events
  • Data Collection
  • Application info
  • Cache events
  • Console commands
  • Custom context
  • Database transactions
  • Dumps
  • Errors when tracing
  • Exception context
  • External http requests
  • Filesystem operations
  • Git information
  • Glows
  • Identifying users
  • Jobs and queues
  • Queries
  • Redis commands
  • Requests
  • Routing
  • Server info
  • Spans
  • Stacktrace arguments
  • Views
  • Older Packages
  • Flare Client PHP V2
  • Flare Client PHP V1

Introduction

Flare collects errors and exceptions thrown in your PHP 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 PHP client is framework agnostic, so it doesn't hook into a global exception handler on its own. There are two ways to make errors reach Flare.

Registering the global handlers

Call registerFlareHandlers() once during bootstrap to register Flare as PHP's exception and error handler. After that, any uncaught throwable and any PHP error that matches your configured severity levels is reported automatically:

$flare->registerFlareHandlers();

If you only want one of the two, the individual methods are available as well:

$flare->registerExceptionHandler();
$flare->registerErrorHandler(E_ALL & ~E_NOTICE);

Reporting manually

When you catch a throwable yourself, hand it to Flare with reportHandled():

try {
    // ...
} catch (Throwable $exception) {
    $flare->reportHandled($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 on the FlareConfig if you want to filter low severity noise:

$config->reportErrorLevels(E_ALL & ~E_NOTICE);

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. 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.
  • Exception context. Attach context to a specific exception class.
  • Identifying users. Attach the authenticated user to a report.
  • Stacktrace arguments. Include the arguments passed to each frame.
Flare daemon Customise error report
  • On this page
  • How errors get to Flare
  • Data collection with errors

Catch errors and fix slowdowns with Flare, the full-stack application monitoring platform for Laravel, PHP & JavaScript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Insights
  • Newsletter
  • Changelog
  • Documentation
  • Affiliate program
  • uptime status badge Service status
  • Terms of use
  • DPA
  • Privacy & cookie Policy
Made in by
Flare