Flare by Spatie
    • Error Tracking
    • Performance Monitoring
    • Logs
  • Pricing
  • Docs
  • Insights
  • Changelog
  • Back to Flare ⌘↵ Shortcut: Command or Control Enter
  • Sign in
  • Try Flare for free
  • Error Tracking
  • Performance Monitoring
  • Logs
  • 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 Svelte Svelte Protocol Protocol
  • General
  • Installation
  • Censoring collected data
  • Ignoring collected data
  • Flare daemon
  • Laravel Octane
  • Laravel Vapor
  • Errors
  • Introduction
  • Customise error report
  • Customising error grouping
  • Linking to errors
  • Logs
  • Introduction
  • Levels
  • With errors
  • Performance
  • Introduction
  • Sampling
  • Limits
  • Modify spans and span 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
  • Laravel context
  • Livewire
  • Queries
  • Redis commands
  • Requests
  • Server info
  • Spans
  • Stacktrace arguments
  • Views
  • Advanced
  • Modifying the configuration
  • Older Packages
  • Laravel Flare V2
  • Laravel Flare V1
  • Ignition

Modifying the configuration

Most of Flare's behaviour is configured through the config/flare.php file. Some things cannot be expressed there, for example a closure that adds custom attributes to the resource, or swapping out a recorder. For those cases you can register a callback that receives the FlareConfig before Flare boots.

use Spatie\FlareClient\Resources\Resource;
use Spatie\LaravelFlare\FlareConfig;
use Spatie\LaravelFlare\FlareServiceProvider;

FlareServiceProvider::configure(function (FlareConfig $config) {
    $config->configureResource(
        fn (Resource $resource) => $resource->addAttribute('team.owner', 'payments'),
    );
});

The callback can change anything on the FlareConfig, so besides the resource you can also adjust recorders, sampling, or the sender.

Where to register the callback

Flare's service provider registers before your application's own providers, so registering the callback in a service provider is too late. Register it in bootstrap/app.php, next to Flare::handles(), which runs before Flare boots:

use Spatie\FlareClient\Resources\Resource;
use Spatie\LaravelFlare\Facades\Flare;
use Spatie\LaravelFlare\FlareConfig;
use Spatie\LaravelFlare\FlareServiceProvider;

->withExceptions(function (Exceptions $exceptions) {
    Flare::handles($exceptions);

    FlareServiceProvider::configure(function (FlareConfig $config) {
        $config->configureResource(
            fn (Resource $resource) => $resource->addAttribute('team.owner', 'payments'),
        );
    });
})
Views Laravel Flare V2

On this page

  • Where to register the callback

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 Spatie logo
Flare