PHPackages                             elkady/activity-logger - 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. elkady/activity-logger

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

elkady/activity-logger
======================

A Laravel package for logging auths activities.

v2.2.0(3w ago)429MITPHPPHP &gt;=8.1

Since Aug 3Pushed 3w agoCompare

[ Source](https://github.com/KarimEl-Kady/activity-logger)[ Packagist](https://packagist.org/packages/elkady/activity-logger)[ RSS](/packages/elkady-activity-logger/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

Laravel Activity Logger
=======================

[](#laravel-activity-logger)

A Laravel package for automatically logging authenticated users' actions (create, update, delete, restore) on any model using the `HasActivityLogs` trait.

---

Features
--------

[](#features)

- 🔄 **Automatic Logging** via Laravel Observers — no manual calls required
- ⚙️ **Trait-Driven** — add `HasActivityLogs` to any model you want tracked, no config list to maintain
- 🔐 **Multi-Guard Aware** — resolves the causer across web, api, admin, or any custom guard
- 🔗 **Polymorphic Relations** — logs both the causer and the affected model
- 🛠 **Easy Integration** — install, configure, done
- ♻️ **Soft-Delete Aware** — logs `restored` in addition to `created`/`updated`/`deleted`
- 📊 **Filterable Reports** — query logs by subject, causer, action, or date range with chainable Eloquent scopes
- 🖥 **Built-in Report Page** — an optional, ready-made filterable UI, no front-end work required

---

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

[](#installation)

Install the package via Composer:

```
composer require elkady/activity-logger
```

### After installation you have to publish the config file

[](#after-installation-you-have-to-publish-the-config-file)

```
php artisan vendor:publish --provider="Elkady\ActivityLogger\ActivityLoggerServiceProvider" --tag=config
```

This will create a config file at:

```
config/activity-logger.php

```

then you have to migrate the added database:

```
php artisan migrate
```

Usage
-----

[](#usage)

Add `HasActivityLogs` to any model you want to track — that's what turns on logging for it, no config array required:

```
use Elkady\ActivityLogger\Traits\HasActivityLogs;

class Post extends Model
{
    use HasActivityLogs;
}
```

Every `created`, `updated`, `deleted`, and `restored` event on `Post` is now logged automatically, attributed to whichever guard-authenticated user performed it. Read them back via the relation the trait adds:

```
$post->activityLogs; // logs recorded about this Post
```

Reports &amp; Filtering
-----------------------

[](#reports--filtering)

`ActivityLog` ships with scopes so you can build reports without writing raw queries:

```
use Elkady\ActivityLogger\Models\ActivityLog;

// everything that happened to a given Post
ActivityLog::forSubject($post)->get();

// everything a given user did
ActivityLog::causedBy($user)->get();

// combine, filter by action, filter by date range, paginate
ActivityLog::forSubject($post)
    ->causedBy($user)
    ->ofAction(['updated', 'deleted'])
    ->between('2026-01-01', '2026-07-22')
    ->latest()
    ->paginate(25);

// filter by type only, without a specific instance
ActivityLog::forSubject(Post::class)->ofAction('deleted')->get();
```

Report UI
---------

[](#report-ui)

The package includes an optional, self-contained report page — a filter bar (action, subject type, causer type, date range) plus a paginated table — with no front-end setup required. It's off by default. Turn it on in `config/activity-logger.php`:

```
'ui' => [
    'enabled' => true,
    'path' => 'activity-logs',
    'middleware' => ['web', 'auth'], // add your own auth middleware here
],
```

The package has no opinion on who should be allowed to view the logs, so **always add your own auth middleware** (or a custom gate-based middleware) to `ui.middleware` before enabling it — otherwise the page is open to anyone who can reach the route.

Visit `/activity-logs` (or whatever `ui.path` is set to) to see it. To customize the look, publish the view:

```
php artisan vendor:publish --provider="Elkady\ActivityLogger\ActivityLoggerServiceProvider" --tag=views
```

Update the Config File
----------------------

[](#update-the-config-file)

In `config/activity-logger.php`, list the guards to check for the current user and which lifecycle events to record:

```
return [
    'guards' => ['web', 'api'],

    'log_actions' => ['created', 'updated', 'deleted', 'restored'],
];
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance94

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~50 days

Total

8

Last Release

27d ago

Major Versions

v1.2.1 → v2.0.02026-07-22

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/54458080?v=4)[Karim El-Kady](/maintainers/KarimEl-Kady)[@KarimEl-Kady](https://github.com/KarimEl-Kady)

---

Top Contributors

[![KarimEl-Kady](https://avatars.githubusercontent.com/u/54458080?v=4)](https://github.com/KarimEl-Kady "KarimEl-Kady (11 commits)")

### Embed Badge

![Health badge](/badges/elkady-activity-logger/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k31.8M161](/packages/laravel-cashier)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45844.8k1](/packages/pressbooks-pressbooks)[moonshine/moonshine

Laravel administration panel

1.3k268.2k89](/packages/moonshine-moonshine)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

731189.9k16](/packages/tallstackui-tallstackui)

PHPackages © 2026

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