PHPackages                             threls/activity-log - 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. threls/activity-log

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

threls/activity-log
===================

This is my package activity-log

2.0.1(2mo ago)02.7k↑64.3%MITPHPPHP ^8.4CI passing

Since Feb 11Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/threls/activity-log)[ Packagist](https://packagist.org/packages/threls/activity-log)[ Docs](https://github.com/threls/activity-log)[ GitHub Sponsors](https://github.com/threls)[ RSS](/packages/threls-activity-log/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (27)Versions (33)Used By (0)

This is my package activity-log
===============================

[](#this-is-my-package-activity-log)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d086f64a1e63e6ea7580773300f33bf9667788fbe6acfe1d687a30cd13e839df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746872656c732f61637469766974792d6c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/threls/activity-log)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bfd541004ada2adde3b5a0d7a38012132d6b8e82ba7714c65af6a813f7ab58b6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746872656c732f61637469766974792d6c6f672f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/threls/activity-log/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/384acc81f6d1b9eb7189d0684a32d87d31871b10c7ab49fb573729a8a5cb27c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746872656c732f61637469766974792d6c6f672f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/threls/activity-log/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ba1f7da0bcf6da31be5d4b9bc3a145acc361de0f55b01e423d6003816d72347a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746872656c732f61637469766974792d6c6f672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/threls/activity-log)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/6b9df5e425f91499173cf2802ba35767cccf8c61a137a5c2e6c3212f964687fc/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f61637469766974792d6c6f672e6a70673f743d31)](https://spatie.be/github-ad-click/activity-log)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require threls/activity-log
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="activity-log-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="activity-log-config"
```

This is the contents of the published config file:

```
return [

    'enabled' => env('ACTIVITY_LOG_ENABLED', true),

    'log_events' => [
        'on_create' => true,
        'on_update' => true,
        'on_delete' => true,
        'on_login' => true,
    ],

    // When true, updates will only log changed (dirty) attributes
    'log_only_dirty' => true,

    // The User model class used to resolve causer name/id
    'user_model' => '\App\Models\User',

    // Which attribute on the causer to display in descriptions (e.g. name/email)
    'causer_name_attribute' => 'name',

    // Global fallback identifier used in descriptions when a model doesn't override it
    'default_log_identifier' => 'id',

    // API listing pagination size
    'log_pagination' => 20,

    // Middleware used by the built-in logs API route
    'api_route_middleware' => 'auth:sanctum',

    // Number of days to retain logs before pruning (default 365)
    'retention_days' => 365,
];
```

Usage
-----

[](#usage)

- Add the `LogsActivity` trait to any model you want to track.
- Implement `ActivityLogContract` to strongly define your model's logging configuration.
- By default, descriptions are standardized as: `"{causerName} {verb} {ModelName} '{identifier}'"`.

### Basic

[](#basic)

```
use Threls\ThrelsActivityLog\Traits\LogsActivity;

class Product extends Model
{
    use LogsActivity;
}
```

This will emit logs like: `Sabina created Product '42'` using the global `default_log_identifier`.

### Per-model configuration via properties (no interface)

[](#per-model-configuration-via-properties-no-interface)

```
class Product extends Model
{
    use LogsActivity;

    public ?array $logAttributes = ['name', 'price'];
    public ?array $ignoreAttributes = ['updated_at'];
    public ?bool $logOnlyDirty = true; // only diffs on update
    public ?string $logIdentifier = 'name'; // used in description
}
```

### Strict configuration via interface

[](#strict-configuration-via-interface)

```
use Threls\ThrelsActivityLog\Contracts\ActivityLogContract;
use Threls\ThrelsActivityLog\Enums\ActivityLogTypeEnum;

class Product extends Model implements ActivityLogContract
{
    use LogsActivity;

    public function getLogAttributes(): array|string|null { return ['name', 'price']; }
    public function getIgnoreAttributes(): array|string|null { return ['updated_at']; }
    public function getLogOnlyDirty(): ?bool { return true; }
    public function getLogIdentifier(): ?string { return 'name'; }
}
```

### CLI / Queues safety

[](#cli--queues-safety)

- The package guards request-dependent values (user agent, IP). In non-HTTP contexts, defaults like `unknown` and `127.0.0.1` are used.

### Maintenance

[](#maintenance)

#### Log Pruning (Recommended)

[](#log-pruning-recommended)

This package supports Laravel's native model pruning. To keep your `activity_log` table small, you should schedule the `model:prune` command in your application's `routes/console.php` (or `app/Console/Kernel.php` for older Laravel versions):

```
use Illuminate\Support\Facades\Schedule;
use Threls\ThrelsActivityLog\Models\ActivityLog;

Schedule::command('model:prune', [
    '--model' => [ActivityLog::class],
])->daily();
```

You can configure the retention period in `config/activity-log.php`:

```
'retention_days' => 365, // Keep logs for 1 year
```

#### Manual Cleanup

[](#manual-cleanup)

Alternatively, you can manually delete old logs using the provided command:

```
# Deletes logs older than 30 days
php artisan activity-log:delete --older-than-days=30

# Deletes logs using the 'retention_days' from config
php artisan activity-log:delete
```

#### Built-in API to list logs

[](#built-in-api-to-list-logs)

```
GET /threls-activity-log/logs
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [sabina](https://github.com/sabina)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance85

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 89.8% 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 ~20 days

Recently: every ~53 days

Total

22

Last Release

78d ago

Major Versions

1.1.9 → 2.0.02026-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/9df53c3802e28d202e6662582378129ec1884b172a715c133bad2730a15ef891?d=identicon)[threls](/maintainers/threls)

---

Top Contributors

[![sabina1997](https://avatars.githubusercontent.com/u/41695168?v=4)](https://github.com/sabina1997 "sabina1997 (53 commits)")[![ableta](https://avatars.githubusercontent.com/u/18583652?v=4)](https://github.com/ableta "ableta (6 commits)")

---

Tags

laravelactivity-logthrels

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/threls-activity-log/health.svg)

```
[![Health](https://phpackages.com/badges/threls-activity-log/health.svg)](https://phpackages.com/packages/threls-activity-log)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

167558.4k1](/packages/keepsuit-laravel-opentelemetry)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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