Search by

roundly-consulting / metrics-for-laravel

mihaliak

Calculate value, trend, progress, and partition metrics from any Eloquent query.

Package info

github.com/roundly-consulting/metrics-for-laravel

pkg:composer/roundly-consulting/metrics-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 17:57 UTC

This package is auto-updated.

Last update: 2026-10-03 18:06:30 UTC


README

Metrics for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

Metrics for Laravel

Turn any Eloquent query into a ready-to-render dashboard metric: a single value with period-over-period change, a time series for charts, progress against a target, or a partitioned breakdown. Date ranges, timezones, aggregation, caching and formatting are handled for you, and the result comes back as clean JSON for any front-end — no admin panel required.

Installation

Requires PHP 8.4 and Laravel 12 or 13.

composer require roundly-consulting/metrics-for-laravel

Usage

Build a metric inline from any query — toArray() is the JSON-ready envelope:

use App\Models\Order;
use App\Models\User;
use RoundlyConsulting\Metrics\Enums\Period;
use RoundlyConsulting\Metrics\Facades\Metrics;

Metrics::value()->count(User::query())
    ->range(Period::Today)
    ->withChangeAgainstPreviousPeriod()
    ->toArray();

Metrics::trend()->count(User::query(), 'created_at')->daily()->range(Period::MonthToDate)->toArray();
Metrics::progress()->sum(Order::query(), 'total')->target(10000)->range(Period::MonthToDate)->toArray();
Metrics::partition()->count(User::query(), 'plan')->limit(5)->toArray();

Or read the typed result in PHP:

$revenue = Metrics::value()->sum(Order::query(), 'total')->range(Period::ThisMonth)->result();

$revenue->value();   // 15230.0

Register metrics under keys and return a whole dashboard from one endpoint:

Metrics::register('signups', fn () => Metrics::value()->name('Sign-ups')->count(User::query()));
Metrics::register('revenue', fn () => Metrics::progress()->name('Revenue')->sum(Order::query(), 'total')->target(10000));

return Metrics::dashboard(['signups', 'revenue'])->range(Period::ThisMonth);   // Responsable: JSON

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/metrics-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

The MIT License (MIT). Please see License File for more information.