PHPackages                             lulzshadowwalker/laravel-metrics - 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. lulzshadowwalker/laravel-metrics

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

lulzshadowwalker/laravel-metrics
================================

Simple metrics for Laravel applications

v1.0.2(4d ago)011↓50%MITPHP ^8.4

Since Jul 7Compare

[ Source](https://github.com/lulzshadowwalker/laravel-metrics)[ Packagist](https://packagist.org/packages/lulzshadowwalker/laravel-metrics)[ RSS](/packages/lulzshadowwalker-laravel-metrics/feed)WikiDiscussions Synced today

READMEChangelogDependencies (7)Versions (3)Used By (0)

Laravel Metrics
===============

[](#laravel-metrics)

A minimal, no-frills way to record and query historical events on your Eloquent models. Inspired by [aarondfrancis/eventable](https://github.com/aarondfrancis/eventable), which does a lot more than this package does. If you need something more full-featured, use that instead.

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

[](#installation)

```
composer require lulzshadowwalker/laravel-metrics
```

Then publish the migration and config, and migrate:

```
php artisan vendor:publish --tag=metrics-migrations
php artisan vendor:publish --tag=metrics-config
php artisan migrate
```

Usage
-----

[](#usage)

Add the `HasMetrics` trait to any model you want to record events against:

```
use Metrics\Traits\HasMetrics;

class Tenant extends Model
{
    use HasMetrics;
}
```

Define your own enum for the events you want to track. This package doesn't ship one, since every app's events are different:

```
enum Metric: string
{
    case SignedUp = 'signed_up';
    case OrderPlaced = 'order_placed';
    case HumanEscalated = 'human_escalated';
}
```

Record events:

```
$tenant->record(Metric::OrderPlaced, ['channel' => 'web']);

// meta is optional
$tenant->record(Metric::HumanEscalated);
```

`record()` also accepts a plain string if you don't want to use an enum.

Query events:

```
$tenant->metrics()->type(Metric::OrderPlaced)->today()->count();

$tenant->metrics()
    ->type(Metric::HumanEscalated)
    ->period(now()->subDays(30), now())
    ->count();
```

Available scopes
----------------

[](#available-scopes)

- `type(string|BackedEnum $type)` — filter by event type
- `today()` — events created today
- `period(Carbon $from, Carbon $to)` — events created within an inclusive date range

Extending the Event model
-------------------------

[](#extending-the-event-model)

If you need extra columns (a `tenant_id`, for example), extend the base model:

```
namespace App\Models;

use Metrics\Models\Event as BaseEvent;

class Event extends BaseEvent
{
    //
}
```

Add whatever columns you need via a new migration, then point the package at your model in `config/metrics.php`:

```
return [
    'model' => \App\Models\Event::class,
];
```

Every model using `HasMetrics` will now use `App\Models\Event` instead of the package's default. This is a single, app-wide setting, not something you configure per model.

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance99

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

4d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d37b00c569d884961f317e4f4fde53cbf200660097ba7c520ae40360b24d5d66?d=identicon)[lulzshadowwalker](/maintainers/lulzshadowwalker)

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/lulzshadowwalker-laravel-metrics/health.svg)

```
[![Health](https://phpackages.com/badges/lulzshadowwalker-laravel-metrics/health.svg)](https://phpackages.com/packages/lulzshadowwalker-laravel-metrics)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M170](/packages/spatie-laravel-health)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)

PHPackages © 2026

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