PHPackages                             cosmastech/laravel-wide-load - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. cosmastech/laravel-wide-load

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

cosmastech/laravel-wide-load
============================

Wide event logging for Laravel — one log to rule them all.

0.1.0(1mo ago)581[1 PRs](https://github.com/cosmastech/laravel-wide-load/pulls)MITPHPPHP ^8.3CI passing

Since Feb 3Pushed 1mo agoCompare

[ Source](https://github.com/cosmastech/laravel-wide-load)[ Packagist](https://packagist.org/packages/cosmastech/laravel-wide-load)[ RSS](/packages/cosmastech-laravel-wide-load/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (16)Versions (7)Used By (0)

 [![Wide Load for Laravel](assets/logo.png)](assets/logo.png)

Wide Load for Laravel
=====================

[](#wide-load-for-laravel)

Wide event logging for Laravel — one log line for an entire request, packed with everything that happened.

Instead of scattering dozens of log lines throughout your request lifecycle, Wide Load collects key-value data as your application runs and emits a single, rich log entry when the request, artisan command, or job completes. This is the "wide event" or "canonical log line" pattern. For more details on the benefits of this approach, see [loggingsucks.com](https://loggingsucks.com).

Installation
------------

[](#installation)

```
composer require cosmastech/laravel-wide-load
```

The package auto-discovers its service provider — no manual registration needed.

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=wide-load-config
```

This creates `config/wide-load.php` with the following options:

OptionEnv VarDefaultDescription`auto_report``WIDE_LOAD_AUTO_REPORT``true`Toggle for automatic reporting. When `false`, lifecycle event-driven reporting is skipped. Manual calls to `report()` still work.`log_level``WIDE_LOAD_LOG_LEVEL``info`Log level used by the default reporter.`log_message``WIDE_LOAD_LOG_MESSAGE``Request completed.`Log message used by the default reporter.`serializable``WIDE_LOAD_SERIALIZABLE``true`Carry wide load data across queued jobs via Laravel's Context serialization.### Enabling auto-reporting

[](#enabling-auto-reporting)

By default, auto-reporting is enabled. You can disable it globally via the config, or toggle it at runtime on a per-request/job basis:

```
use Cosmastech\WideLoad\Facades\WideLoad;

// Enable auto-reporting for this lifecycle (request, job, or command)
WideLoad::enableAutoReporting();

// Disable it
WideLoad::enableAutoReporting(false);

// Check if enabled
WideLoad::isAutoReportingEnabled();
```

Since `WideLoad` is a [scoped singleton](https://laravel.com/docs/container#scoped-bindings), the auto-reporting flag resets between requests and queue jobs. This makes it safe to enable reporting in specific services without affecting other jobs processed by the same worker.

Usage
-----

[](#usage)

### Via the Facade

[](#via-the-facade)

The quickest way to add data from anywhere in your app:

```
use Cosmastech\WideLoad\Facades\WideLoad;

// Add data
WideLoad::add('user_id', $user->id);
WideLoad::add(['plan' => 'pro', 'locale' => 'en']);

// Add only if the key doesn't exist yet
WideLoad::addIf('request_id', Str::uuid());

// Increment a counter
WideLoad::increment('db_queries');
WideLoad::decrement('remaining_credits');
```

### Automatic reporting

[](#automatic-reporting)

Wide Load automatically calls `report()` and `flush()` on:

- `Terminating` (end of HTTP request)
- `CommandFinished` (end of Artisan command)
- `JobProcessed` (successful queue job)
- `JobFailed` (failed queue job)

No manual reporting is needed in most cases if you have `auto_report` enabled.

### Middleware

[](#middleware)

For more control over HTTP request reporting, you can register the terminable middleware:

```
// bootstrap/app.php
use Cosmastech\WideLoad\Http\Middleware\WideLoadMiddleware;

->withMiddleware(function (Middleware $middleware) {
    $middleware->append(WideLoadMiddleware::class);
})
```

When the middleware is registered, it will report and flush during the `terminate` phase. The `Terminating` event listener will automatically skip reporting if the middleware has already handled it, so there is no double-reporting.

### Custom reporter

[](#custom-reporter)

By default, Wide Load writes to the Laravel log. To send data somewhere else (a metrics service, a dedicated wide event store, etc.), register a custom callback in your `AppServiceProvider`:

```
use Cosmastech\WideLoad\Facades\WideLoad;
use Illuminate\Support\Facades\Log;

public function boot(): void
{
    WideLoad::reportUsing(static function (array $data): void {
        if (empty($data)) {
            return;
        }

        Log::info("[Shutdown] Request details", $data);
    });
}
```

Events
------

[](#events)

Wide Load dispatches events during the `report()` call that you can listen to:

EventDescription`WideLoadReporting`Dispatched when `report()` is called with data. The event contains the `array $data` being reported.`NoWideLoadToReport`Dispatched when `report()` is called but there is no data to report.```
use Cosmastech\WideLoad\Events\WideLoadReporting;
use Cosmastech\WideLoad\Events\NoWideLoadToReport;
use Illuminate\Support\Facades\Event;

Event::listen(WideLoadReporting::class, function (WideLoadReporting $event) {
    // $event->data contains the reported key-value pairs
});

Event::listen(NoWideLoadToReport::class, function () {
    // No wide load data was collected during this lifecycle
});
```

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance92

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~29 days

Total

3

Last Release

40d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4bb00a9977a8feb9d2b17a7d1c901126d0df89483f11cbb27332008a0a6595c4?d=identicon)[cosmastech](/maintainers/cosmastech)

---

Top Contributors

[![cosmastech](https://avatars.githubusercontent.com/u/42181698?v=4)](https://github.com/cosmastech "cosmastech (40 commits)")[![jackbayliss](https://avatars.githubusercontent.com/u/13621738?v=4)](https://github.com/jackbayliss "jackbayliss (2 commits)")

---

Tags

laravelloggingwide-eventcanonical-log-line

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cosmastech-laravel-wide-load/health.svg)

```
[![Health](https://phpackages.com/badges/cosmastech-laravel-wide-load/health.svg)](https://phpackages.com/packages/cosmastech-laravel-wide-load)
```

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90234.6M36](/packages/bugsnag-bugsnag-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[naoray/laravel-github-monolog

Log driver to store logs as github issues

10619.4k](/packages/naoray-laravel-github-monolog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
