Guidance for working in this repository.
spatie/laravel-flare is the Laravel adapter for spatie/flare-client-php. The client package owns all framework-agnostic behaviour (reporting, tracing, recorders, senders, the HTTP API, the lifecycle state machine). This package adds the Laravel-specific glue.
Belongs in spatie/flare-client-php:
- Anything that can run without Laravel installed.
- Core abstractions:
Flare,Tracer,FlareProvider, the baseFlareConfig,Lifecycle,Report,Span, plus recorders/middleware/senders that only need PHP. - The
Testerbase class.
Belongs in spatie/laravel-flare:
- Anything that touches
Illuminate\*, facades, Eloquent, Blade, Livewire, Octane, or Vapor. - Laravel subclasses of client base classes (e.g.
LaravelStacktraceMapper,LaravelTester,LaravelHttpSender, recorders undersrc/Recorders/that consume Laravel events). - The service provider that wires everything into the container.
When adding behaviour, default to extending an existing client class on the Laravel side rather than spinning up a new value object. If a feature is useful outside Laravel, push it down into the client package and subclass here.
register():
- Merges
config/flare.phpand hydrates aFlareConfigviaFlareConfig::fromLaravelConfig(). The LaravelFlareConfigextends the client'sFlareConfigand is aliased to the base class in the container. - Constructs a
FlareProvider(from the client package) with the config, the container, and a handful of Laravel-specific closures (recorder registration callback, subtask detection, graceful span ender). - Registers Laravel-only singletons (
BackTracer,LaravelStacktraceMapper, view frame mappers, Livewire support). - Extends
ResourceandScopewith Laravel telemetry attributes. - Calls
$provider->register(), which binds all configured recorders and Flare middleware.
boot():
- Publishes the config stub and registers
TestCommand. - Calls
$provider->boot(). - Wires Octane event listeners for subtask lifecycle.
- Maps
ViewExceptionthrough the framework exception handler. - Drives the client
Lifecyclestate machine (start,register,registered,boot,booted,terminating,terminated) using Laravel's container hooks. - If tracing is enabled, extends the route dispatchers and prepends
FlareTracingMiddleware.
FlareConfig::fromLaravelConfig() reads config/flare.php into a typed FlareConfig. Two rules apply:
- Helpers called from a config file must never throw. Return
nullon bad input and filter at the call site. Config files load extremely early; an exception there breaks the whole app. - Unknown
collectstypes are silently skipped viatryFrom. This is deliberate so configs can reference recorders that may not exist in older versions.
FlareMiddleware/: per-report enrichers (request info, console info, view info, exception context, handled status). Runs synchronously when a report is built.Recorders/: long-lived collectors for cache, queries, jobs, queues, HTTP, filesystem, Livewire, notifications, routing, transactions, views, etc. Subscribe to Laravel events and feed spans/breadcrumbs.Sampling/:SamplingRulesubclasses (route name, route action, queue name, queue connection) consumed by the client's sampler.Senders/: Laravel-specific transports (LaravelHttpSender,LaravelVaporSender).ArgumentReducers/: turn Laravel-specific argument types (Eloquent models, collections, views) into reportable representations.AttributesProviders/: produce OpenTelemetry attributes for requests, routes, jobs, commands, users, Livewire components.Http/:FlareTracingMiddlewareplus route dispatcher wrappers that open spans around controller/closure dispatch.Commands/:TestCommand(flare:test).Jobs/SendFlarePayload.php: queued job for async sending.Views/: Blade source map compiler, view exception mapper, view/Livewire frame mappers. Used to translate compiled-Blade stack frames back to source.Support/: small Laravel-aware utilities (BackTracer,CollectsResolver,FlareLogHandler,Telemetry,LivewireComponentFinder,LaravelStacktraceMapper).Enums/,Exceptions/,Facades/,Filesystem/: small support types.
The client package mirrors much of this layout under vendor/spatie/flare-client-php/src/ and is the source of truth for shared abstractions.
The suite includes integration tests that hit a running workbench HTTP server and queue worker. Without those running, ~64 integration tests will fail. The full sequence:
composer install
composer run build # builds the workbench (migrations, storage symlink, etc.)
vendor/bin/testbench serve & # http server
vendor/bin/testbench queue:work & # queue worker
vendor/bin/pest # run all testsAfter the suite finishes, kill the background processes:
pkill -f "testbench serve"
pkill -f "testbench queue:work"For unit tests only (no workbench needed):
vendor/bin/pest --exclude-group=integrationWhen changes to spatie/flare-client-php need verification against this package, symlink the local checkout via a path repository instead of editing vendor/ by hand.
Add the following to composer.json (next to config):
"repositories": [
{
"type": "path",
"url": "../flare-client-php",
"options": { "symlink": true }
}
],
"minimum-stability": "dev",
"prefer-stable": trueThen:
composer update spatie/flare-client-php --with-all-dependenciesVerify the symlink with ls -la vendor/spatie/flare-client-php (should show -> ../../../flare-client-php/).
Run the full integration suite as above to catch regressions.
To reset, back up composer.json and composer.lock before linking, then restore them and run composer install after testing.