PHPackages                             mhamed/spatie-activitylog-browse - 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. mhamed/spatie-activitylog-browse

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

mhamed/spatie-activitylog-browse
================================

Auto-log all models, enrich with request/device data, and browse activity logs via a web UI

v1.0.8(2mo ago)0904↓48.3%MITBladePHP ^8.1

Since Feb 14Pushed 2mo agoCompare

[ Source](https://github.com/mahmoud-mhamed/spatie-activitylog-browse)[ Packagist](https://packagist.org/packages/mhamed/spatie-activitylog-browse)[ RSS](/packages/mhamed-spatie-activitylog-browse/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (4)Versions (10)Used By (0)

Activity Log Browse
===================

[](#activity-log-browse)

[![Latest Version on Packagist](https://camo.githubusercontent.com/77d2c33d6007ec84cfa07e0c051dd3ae329a85b82a9bb7221c673f06ac6b50bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d68616d65642f7370617469652d61637469766974796c6f672d62726f7773652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mhamed/spatie-activitylog-browse)[![License](https://camo.githubusercontent.com/92d173556003dd3f5ba51251d0974274803afa550e29fc27678498c7ea7c93f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d68616d65642f7370617469652d61637469766974796c6f672d62726f7773652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mhamed/spatie-activitylog-browse)[![PHP Version](https://camo.githubusercontent.com/fa2f8a63f985e42f54896bcf59eccf193aca42c99d07e18d5edf9ec1b97ddd9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d68616d65642f7370617469652d61637469766974796c6f672d62726f7773652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mhamed/spatie-activitylog-browse)

A Laravel package that extends [spatie/laravel-activitylog](https://github.com/spatie/laravel-activitylog) v4 with automatic model logging, rich contextual enrichment, a web-based log browser, and a statistics dashboard.

Features
--------

[](#features)

- **Auto-log all models** — Automatically log created/updated/deleted events for all Eloquent models without adding the `LogsActivity` trait
- **Rich enrichment** — Attach request, device, performance, app, session, and execution context data to every log entry
- **Browse UI** — Web interface to view, filter, search, and inspect activity logs with quick-preview popovers and color-coded diffs
- **Statistics dashboard** — Comprehensive analytics page with charts, breakdowns, and peak-time analysis
- **Related model browsing** — Navigate between related model logs via auto-discovered Eloquent relationships
- **Model info sidebar** — View model stats, table size, and clickable attribute chips to filter by changed attributes
- **Attribute translation** — Attribute names are translated using Laravel's `validation.attributes` lang file throughout the UI
- **Localization** — Built-in support for English and Arabic with RTL layout

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Browse UI](#browse-ui)
- [Statistics Dashboard](#statistics-dashboard)
- [Localization](#localization)
- [Multi-Tenancy](#multi-tenancy)
- [Architecture](#architecture)
- [License](#license)

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12
- spatie/laravel-activitylog ^4.0

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

[](#installation)

```
composer require mhamed/spatie-activitylog-browse
```

If auto-discovery doesn't work, register the provider manually in `bootstrap/providers.php` (Laravel 11+) or `config/app.php`:

```
Mhamed\SpatieActivitylogBrowse\ActivitylogBrowseServiceProvider::class,
```

Then run the install command. This publishes the spatie migration, the package config, and runs migrations:

```
php artisan activitylog-browse:install
```

Or publish individually:

```
# Spatie migration
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
php artisan migrate

# Package config
php artisan vendor:publish --tag=activitylog-browse-config

# Views (optional)
php artisan vendor:publish --tag=activitylog-browse-views

# Language files (optional)
php artisan vendor:publish --tag=activitylog-browse-lang

# Migrations (optional — for multi-tenancy setups)
php artisan vendor:publish --tag=activitylog-browse-migrations
```

> **Tip:** Use `--force` to overwrite previously published files (e.g., after updating the package):
>
> ```
> php artisan vendor:publish --tag=activitylog-browse-config --force
> php artisan vendor:publish --tag=activitylog-browse-views --force
> php artisan vendor:publish --tag=activitylog-browse-lang --force
> ```

### Local Development

[](#local-development)

To install as a local path repository, add the following to your Laravel app's `composer.json`:

```
"repositories": [
    {
        "type": "path",
        "url": "../spatie-activitylog-browse"
    }
]
```

Then require it:

```
composer require mhamed/spatie-activitylog-browse:@dev
```

Run the install command:

```
php artisan activitylog-browse:install
```

Configuration
-------------

[](#configuration)

After publishing, the config file is located at `config/activitylog-browse.php`. It has the following sections:

### Auto-Log

[](#auto-log)

```
'auto_log' => [
    'enabled' => true,
    'events' => ['created', 'updated', 'deleted'],
    'models' => '*',              // '*' = all models, or array of specific classes
    'excluded_models' => [],
    'log_name' => 'default',
    'log_only_dirty' => true,
    'excluded_attributes' => ['password', 'remember_token', 'two_factor_secret', 'two_factor_recovery_codes'],
    'submit_empty_logs' => false,
],
```

Set `models` to `'*'` to log all models automatically, or pass an array to log only specific ones:

```
'models' => [
    App\Models\User::class,
    App\Models\Order::class,
],
```

Models that already use the `LogsActivity` trait are automatically skipped to prevent duplicate entries.

### Request Data Enrichment

[](#request-data-enrichment)

```
'request_data' => [
    'enabled' => true,
    'fields' => [
        'url' => true,
        'previous_url' => true,
        'method' => true,
        'route_name' => true,
    ],
],
```

### Device Data Enrichment

[](#device-data-enrichment)

```
'device_data' => [
    'enabled' => true,
    'fields' => [
        'ip' => true,
        'user_agent' => true,
        'referrer' => true,
    ],
],
```

### Performance Data Enrichment

[](#performance-data-enrichment)

```
'performance_data' => [
    'enabled' => true,
    'fields' => [
        'request_duration' => true,  // milliseconds since LARAVEL_START
        'memory_peak' => true,       // peak memory usage in bytes
        'db_query_count' => true,    // number of DB queries executed
    ],
],
```

### App Data Enrichment

[](#app-data-enrichment)

```
'app_data' => [
    'enabled' => true,
    'fields' => [
        'environment' => true,       // e.g. "local", "production"
        'php_version' => true,
        'server_hostname' => true,
    ],
],
```

### Session Data Enrichment

[](#session-data-enrichment)

```
'session_data' => [
    'enabled' => true,
    'fields' => [
        'auth_guard' => true,        // the guard used for authentication
    ],
],
```

### Execution Context Enrichment

[](#execution-context-enrichment)

```
'execution_context' => [
    'enabled' => true,
    'fields' => [
        'source' => true,            // "web", "console", "queue", or "schedule"
        'job_name' => true,          // queue job class name
        'command_name' => true,      // artisan command name
    ],
],
```

All enrichment collectors gracefully return empty arrays when running in console/queue context where request data is unavailable.

### Browse UI

[](#browse-ui)

```
'browse' => [
    'enabled' => true,
    'prefix' => 'activity-log',
    'middleware' => ['web', 'auth'],
    'per_page' => 25,
    'gate' => null,
    'available_locales' => ['en', 'ar'],
],
```

Set `gate` to a gate name to restrict access (e.g. `'gate' => 'view-activity-log'`).

Usage
-----

[](#usage)

### Auto-Logging

[](#auto-logging)

Once installed, all Eloquent model events are logged automatically. No trait needed:

```
$user = User::create(['name' => 'John']); // Logged
$user->update(['name' => 'Jane']);         // Logged
$user->delete();                           // Logged
```

To exclude specific models:

```
'excluded_models' => [
    App\Models\TemporaryFile::class,
],
```

### Enrichment

[](#enrichment)

Every activity log entry (including those from the `LogsActivity` trait or manual `activity()` calls) is automatically enriched with contextual data:

```
{
    "attributes": { "name": "Jane" },
    "old": { "name": "John" },
    "request_data": {
        "url": "https://example.com/users/1",
        "method": "PUT",
        "route_name": "users.update"
    },
    "device_data": {
        "ip": "192.168.1.1",
        "user_agent": "Mozilla/5.0 ..."
    },
    "performance_data": {
        "request_duration": 142,
        "memory_peak": 12582912,
        "db_query_count": 8
    },
    "app_data": {
        "environment": "production",
        "php_version": "8.3.0",
        "server_hostname": "web-01"
    },
    "session_data": {
        "auth_guard": "web"
    },
    "execution_context": {
        "source": "web",
        "job_name": null,
        "command_name": null
    }
}
```

Browse UI
---------

[](#browse-ui-1)

Visit `/activity-log` (or your configured prefix) to browse logs. The UI provides:

- **Filtering** — Filter by log name, event type, model type, model ID, causer, date range, and description search
- **Changed attribute filter** — Select a model type, then filter by a specific attribute (e.g. only show logs where `name` changed)
- **Quick preview popover** — Hover on a row's info icon to see old/new value diff without leaving the list
- **Current attributes popover** — View the subject's live model data from the list
- **Model info sidebar** — When a model type is selected, a sidebar appears with model stats (total logs, unique records, table name, table size), event breakdown badges, and clickable attribute chips for quick filtering
- **Related model navigation** — Click through to view all logs for a related model instance
- **Detail view** — Color-coded old/new value diff, request data, device data, performance metrics (with Fast/Normal/Slow badges), app info, session info, execution context, and raw JSON view
- **Language switcher** — Toggle between available locales directly from the UI

### Attribute Translation

[](#attribute-translation)

Throughout the UI, attribute names (database column names like `first_name`, `email_verified_at`) are automatically translated using Laravel's `validation.attributes` language file:

- If a translation exists in `validation.attributes.{key}` — displays the translated name with the original key in parentheses, e.g. **"First Name" (first\_name)**
- If no translation exists — displays a "headline" version of the key, e.g. **"Email Verified At"** with the original key in small text

This applies to the changes table on the detail page, the model info sidebar attribute chips, and the statistics page's "Most Changed Attributes" section.

To add translations, define them in your `lang/{locale}/validation.php`:

```
'attributes' => [
    'first_name' => 'First Name',
    'email' => 'Email Address',
    'created_at' => 'Creation Date',
],
```

Statistics Dashboard
--------------------

[](#statistics-dashboard)

Visit `/activity-log/statistics` to access the statistics dashboard. The page loads each section independently via AJAX for fast initial rendering with skeleton loading states.

### Period Filter

[](#period-filter)

A date range filter at the top applies to all sections. Select "From" and "To" dates and click "Apply" to filter. Click "Reset" to return to all-time data.

### Sections

[](#sections)

The dashboard includes the following sections:

#### Overview Cards

[](#overview-cards)

Five summary cards showing:

- **Total Entries** — Total number of activity log records
- **Table Size** — Database table size (data + indexes)
- **Avg / Day** — Average number of entries per day
- **Oldest Entry** — Date of the first recorded activity
- **Latest Entry** — Date of the most recent activity

#### Peak Hour Chart

[](#peak-hour-chart)

A 24-hour bar chart showing activity distribution by hour of day. The busiest hour is highlighted in orange. Hover over any bar to see the exact count.

#### Daily Activity

[](#daily-activity)

A bar chart showing activity over the last 30 days (or the selected date range). Hover for exact date and count.

#### Activity by Day of Week

[](#activity-by-day-of-week)

A bar chart showing activity distribution across weekdays (Sunday through Saturday). The busiest day is highlighted. Uses localized weekday names.

#### Peak Times Summary

[](#peak-times-summary)

Three cards showing:

- **Busiest Hour** — The hour with the most activity (e.g. "2 PM")
- **Busiest Day** — The single date with the highest activity count
- **Busiest Month** — The month (YYYY-MM) with the most activity

#### Monthly Activity

[](#monthly-activity)

A bar chart showing activity per month across all available data. The peak month is highlighted in orange.

#### System vs User Actions

[](#system-vs-user-actions)

A progress bar comparing activities performed by authenticated users vs system/automated actions (entries without a `causer_id`). Shows exact counts and percentages.

#### Events Breakdown

[](#events-breakdown)

A ranked table showing each event type (`created`, `updated`, `deleted`, etc.) with count and a proportional bar. Events are color-coded with badges.

#### Log Names

[](#log-names)

A ranked table showing activity counts per log name (e.g. `default`, `auth`, `system`).

#### Top Models

[](#top-models)

A ranked table of the 10 most frequently logged model types (shown as class basenames).

#### Top Causers

[](#top-causers)

A ranked table of the 10 most active causers. Resolves causer names from the database when possible (uses `name`, `email`, or `title` attributes).

#### Most Changed Attributes

[](#most-changed-attributes)

A ranked table of the 30 most frequently changed attributes (from `updated` events). Scans the last 1000 update entries. The title shows the active search period or "All Time". Attribute names are translated using `validation.attributes` — showing the human-readable name with the original column name.

### Caching

[](#caching)

Statistics responses are cached:

- **All-time queries**: cached for 120 seconds
- **Date-filtered queries**: cached for 60 seconds

Cache keys are namespaced per section and date range.

Localization
------------

[](#localization)

The package ships with English and Arabic translations. The UI automatically adapts to RTL layout when the locale is `ar`.

Set the locale in your `config/app.php`:

```
'locale' => 'ar',
```

Or switch at runtime:

```
App::setLocale('ar');
```

The browse UI also includes a language switcher button that saves the preference in the session.

To customize translations, publish the language files:

```
php artisan vendor:publish --tag=activitylog-browse-lang
# Use --force to overwrite previously published files
php artisan vendor:publish --tag=activitylog-browse-lang --force
```

This copies the files to `lang/vendor/activitylog-browse/` where you can edit them or add new languages.

Multi-Tenancy
-------------

[](#multi-tenancy)

This package works out of the box with [stancl/tenancy](https://tenancyforlaravel.com/) (multi-database tenancy). It automatically detects the active tenant and isolates cache keys, database connections, and migrations accordingly.

### How It Works

[](#how-it-works)

- **Cache isolation** — Cache keys are automatically prefixed with the tenant ID when a tenant is active (e.g. `activitylog-browse:t:1:stats:overview`). No shared cache between tenants.
- **Database connection** — All queries use the connection defined on your Activity model. In a multi-database tenancy setup, the tenant's connection is used automatically.
- **No extra dependencies** — Tenant detection uses `function_exists('tenant')`, so there's no hard dependency on any tenancy package.

### Setup for Multi-Database Tenancy

[](#setup-for-multi-database-tenancy)

1. **Disable automatic migrations** so they don't run on the central database:

```
// config/activitylog-browse.php
'load_migrations' => false,
```

2. **Publish migrations** to your tenant migration path:

```
php artisan vendor:publish --tag=activitylog-browse-migrations
```

Then move the published migration(s) to your tenant migrations directory (e.g. `database/migrations/tenant/`).

3. **Add tenancy middleware** to the browse UI routes:

```
// config/activitylog-browse.php
'browse' => [
    'middleware' => ['web', 'auth', \Stancl\Tenancy\Middleware\InitializeTenancyByDomain::class],
],
```

### Without Tenancy

[](#without-tenancy)

If you're not using multi-tenancy, everything works exactly as before — no configuration changes needed.

Architecture
------------

[](#architecture)

ComponentRole`GlobalModelLogger`Listens to global Eloquent events and logs activity for models without the `LogsActivity` trait`ActivityEnrichmentObserver`Observes the Activity model's `creating` event to merge all enrichment data into properties before save`RequestDataCollector`Gathers URL, method, route name, previous URL from the current request`DeviceDataCollector`Gathers IP, user agent, referrer from the current request`PerformanceDataCollector`Captures request duration, peak memory usage, and DB query count`AppDataCollector`Records environment, PHP version, and server hostname`SessionDataCollector`Identifies the authentication guard used`ExecutionContextCollector`Determines execution source (web/console/queue/schedule) and captures job/command names`RelationDiscovery`Uses reflection to auto-discover Eloquent relationships for related model browsing`ActivityLogController`Handles the browse UI with filtering, pagination, AJAX endpoints, statistics API, and attribute inspection`SetLocale`Middleware that applies the user's locale preference from the sessionLicense
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance84

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Total

9

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d00c2f8ae29401e1b578e1435eae2629802a0c10e8322e5cb12d701538ff971?d=identicon)[mahmoud-mhamed](/maintainers/mahmoud-mhamed)

---

Top Contributors

[![mahmoud-mhamed](https://avatars.githubusercontent.com/u/45818696?v=4)](https://github.com/mahmoud-mhamed "mahmoud-mhamed (20 commits)")

---

Tags

spatielaravelAuditlog viewerbrowseactivitylog

### Embed Badge

![Health badge](/badges/mhamed-spatie-activitylog-browse/health.svg)

```
[![Health](https://phpackages.com/badges/mhamed-spatie-activitylog-browse/health.svg)](https://phpackages.com/packages/mhamed-spatie-activitylog-browse)
```

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[muhammadsadeeq/laravel-activitylog-ui

A beautiful, modern UI for Spatie's Activity Log with advanced filtering, analytics, and real-time features.

17510.1k](/packages/muhammadsadeeq-laravel-activitylog-ui)[rmsramos/activitylog

This is my package activitylog

309346.5k2](/packages/rmsramos-activitylog)[jackiedo/log-reader

An easy log reader and management tool for Laravel

151376.5k4](/packages/jackiedo-log-reader)[noxoua/filament-activity-log

A Laravel package that simplifies activity logging in the Filament admin panel, with support for logging create, update, delete, and restore actions. It integrates with the 'spatie/laravel-activitylog' package and includes a modernized activity log viewing page.

7151.5k](/packages/noxoua-filament-activity-log)

PHPackages © 2026

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