Search by

flawe / flare-bundle

flawe

Send Symfony errors to Flare

Package info

github.com/f-lawe/flare-bundle

Type:symfony-bundle

pkg:composer/flawe/flare-bundle

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v3.4.0 2026-11-23 22:43 UTC

This package is auto-updated.

Last update: 2026-11-23 22:46:33 UTC


README

Versions Downloads Licence GitHub Actions

Send Symfony errors to Flare! This project is the Symfony counterpart of the Laravel Flare package.

Installation

Install the package via composer:

composer require flawe/flare-bundle

Add the bundle to your Symfony application by adding it to the config/bundles.php file:

return [
    // ...
    Flawe\FlareBundle\FlareBundle::class => ['all' => true],
];

Add your Flare API key to your .env file:

FLARE_KEY=your-flare-key

And finally, add the file config/packages/flare.yaml and fill it with your settings:

flare:
    key: '%env(default::FLARE_KEY)%'
    trace: false
    censor:
        client_ips: true
        body_fields: []
        headers: []
        cookies: true
        session: true

When key is empty or missing, Flare is disabled: nothing is sent and no error is raised.

Usage

The bundle will automatically report all errors to Flare. You can also inject Flare when you need it:

namespace App\Controller;

use Spatie\FlareClient\Flare;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class SomeController
{
    #[Route('/some-action')]
    public function someAction(Flare $flare): Response
    {
        $flare->tracer->span('Do something', function () {
            // Do something
        });

        return new Response('Some Response');
    }
}

Customising Flare services

Flare's internal services (Tracer, Sampler, Sender, recorders, etc.) are private services of the Symfony container, listed by debug:container. Inject Flare and use its properties ($flare->tracer, $flare->log(), etc.) rather than these services. To change one of them, decorate it the Symfony way:

namespace App\Flare;

use Spatie\FlareClient\EntryPoint\EntryPoint;
use Spatie\FlareClient\Sampling\Sampler;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;

#[AsDecorator(Sampler::class)]
final class CustomSampler implements Sampler
{
    public function __construct(
        #[AutowireDecorated] private readonly Sampler $flareSampler,
    ) {
    }

    public function shouldSample(EntryPoint $entryPoint, ?bool $parentSampled = null): bool
    {
        return $this->flareSampler->shouldSample($entryPoint, $parentSampled);
    }
}

Every Flare service using the decorated one gets the decorator.

Configuration

Sender

Payloads are sent to Flare with cURL by default. Use sender to pick another transport (curl, daemon, guzzle or null), with its options:

flare:
    sender:
        type: daemon
        options:
            daemon_url: '%env(default::FLARE_DAEMON_URL)%'

See Flare daemon to run the daemon.

Sampling

Traces are sampled at 10% by default. Use sampling to change the strategy (rate, always or never), the rate, and add per-entry-point rules:

flare:
    sampling:
        rate: 0.2
        rules:
            - { type: path, pattern: '/health', rate: 0 }
            - { type: route, pattern: 'app_checkout_*', rate: 1 }
            - { type: command, pattern: 'app:import*', rate: 0.5 }

Rule types are url, path, route, command and job; patterns accept * as a wildcard. route rules match the Symfony route name. See Sampling.

Logs

Enable log collection to send your application logs to Flare. Logs are also required for collect.logs_with_errors.

flare:
    log:
        enable: true
        level: warning

The bundle hooks into the Symfony logger automatically, while keeping your existing log output (records are only sent to Flare when log.enable is true):

  • with MonologBundle, a flare Monolog handler is registered and receives every channel. Restrict channels in config/packages/monolog.yaml:

    monolog:
        handlers:
            flare:
                channels: ['!event', '!doctrine']
  • without Monolog, the default logger service is decorated: messages are still written by the Symfony logger, and also sent to Flare.

Set log.auto_register: false to disable this integration and only record logs manually with $flare->log()->record().

Logs are sent at the end of each request or console command. See Logs.

Messenger

With Symfony Messenger, the bundle traces messages sent to transports and handled by messenger:consume workers:

  • sending a message records a Queueing span, and stamps the message with the current trace so that the worker continues it;
  • each message handled by a worker is traced as a job (with the job sampling entry point), and its errors are reported to Flare, on every attempt.

Messages handled synchronously (without transport) are not traced as jobs.

Use collect.jobs to disable this tracing (errors are still reported), or to ignore some messages:

flare:
    collect:
        jobs:
            ignored_messages: ['App\Message\Ping', 'App\Message\Health*']

Long-running processes

In long-running processes, every unit of work is traced as a subtask: each request with a FrankenPHP worker or RoadRunner, each message with messenger:consume. Use subtasks (auto, always or never) to override this detection:

flare:
    subtasks: never