NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Metrics for Laravel

Without the facade

The facade is the recommended default, not the only way in. It’s a thin layer over RoundlyConsulting\Metrics\MetricsManager, the facade root — inject it through the constructor for the same API with an explicit dependency and no static calls:

use App\Models\User;
use RoundlyConsulting\Metrics\MetricsManager;

final class DashboardController
{
    public function __construct(private MetricsManager $metrics) {}

    public function __invoke(): array
    {
        return [
            'revenue' => $this->metrics->get('revenue')->result()->value(),
            'signups' => $this->metrics->value()->count(User::query())->range('TODAY')->result()->value(),
        ];
    }
}

Metrics::fake() swaps the manager behind the facade and in the container, so an injected MetricsManager gets the fake too.

Metric classes on their own

A metric class works without the registry or the facade — make it, or resolve it through the container:

RegisteredUsers::make()->range('TODAY')->result();   // ValueResult
app(RegisteredUsers::class)->toArray();             // resolved through the container

No action classes

Metrics is a calculation package, so it has no action classes: the builders and your metric classes are the behaviour, and the manager only registers, resolves and invalidates them.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.