Download the PHP package mahmoud-mhamed/spatie-activitylog-browse without Composer

On this page you can find all versions of the php package mahmoud-mhamed/spatie-activitylog-browse. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package spatie-activitylog-browse

Activity Log Browse

Latest Version on Packagist License PHP Version

A Laravel package that extends spatie/laravel-activitylog v4 with automatic model logging, rich contextual enrichment, a web-based log browser, a statistics dashboard, automatic retention/cleanup, and a deletion audit trail โ€” all with English/Arabic UI, dark mode, and an optional password gate.

Arabic version: README.ar.md

Features

Logging

Browsing & Analytics

Cleanup & Audit

Security

Table of Contents

Requirements

Installation

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

Then run the install command โ€” publishes the spatie migration, the package config, runs migrations, fixes UUID-friendly morph columns, adds performance indexes, and prepares the deletion-history storage:

Re-running install after upgrading the package will offer to refresh your config so new options (e.g. retention, deletion_history) are picked up.

Publishing individual assets

Tip: Use --force to overwrite previously published files after upgrading the package:

Local Development

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

Quick Start

After running activitylog-browse:install:

  1. Open /activity-log in your browser โ€” protected by web + auth middleware by default.
  2. Trigger any model change โ€” it'll appear with full enrichment.
  3. (Optional) Enable retention in config/activitylog-browse.php so old logs prune themselves.
  4. (Optional) Set ACTIVITYLOG_BROWSE_PASSWORD in .env to add a password gate.

Configuration

The published config file is at config/activitylog-browse.php. Key sections below.

Auto-Log

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

Enrichment

Each enrichment section can be enabled/disabled and has per-field toggles. Disabling an entire section removes all per-event overhead for that section.

Show all enrichment options All collectors gracefully return empty data when running outside their context (e.g. request data in console).

Browse UI Config

Set gate to a Laravel Gate name to restrict access; the package will call Gate::authorize($name) on every browse request.

Password Gate

For environments where you want a shared password protecting the browse UI (in addition to whatever auth/middleware you've configured):

When set, users hitting /activity-log are redirected to a login screen. The form is rate-limited to 5 attempts per minute per IP. Authentication is stored in the session โ€” a logout button appears in the navbar when a user is signed in via password.

Set the env variable to an empty value (or remove it) to disable the gate entirely.

Retention / Auto-Cleanup

Automatically prune old activity log entries based on age and table size limits, with per-model overrides for sensitive data that should be kept longer (or forever).

Priority hierarchy (strongest โ†’ weakest)

  1. per_model / per_log_name โ€” always win.
    • 'forever' is fully protected from both age and size pruning.
    • An int day count protects records younger than the configured days from BOTH age and size pruning.
  2. max_rows / max_size_mb โ€” hard size caps. They win over default_days: when the table is over the cap, the oldest records (not protected by a per-model rule) are deleted even if they are still inside the default_days window.
  3. default_days โ€” the catch-all rule. Applies only to records not covered by a higher-priority rule.

What happens at the size limit?

Per-model rule Age-based prune Size-based prune (when max_rows / max_size_mb is hit)
Not configured Deleted after default_days Can be deleted (oldest first)
365 (any int days) Deleted after 365 days Protected while younger than 365 days; older records can be deleted
'forever' Never deleted Never deleted (fully protected)

TL;DR: Per-model retention is the authoritative rule. A model set to 365 days will keep its rows for the full 365 days even if the table is over its size cap โ€” they only become eligible for size pruning after their own retention window expires. The size cap is therefore best-effort: if every record is still inside its per-model retention window, nothing is deleted and the table stays over the cap until the protections expire. Set realistic per-model values to keep the size cap effective.

How it runs

Trigger When
Schedule Automatically at schedule_time (frequency = daily/weekly/monthly). Requires schedule:work or a cron entry calling schedule:run.
CLI php artisan activitylog-browse:prune โ€” see Artisan Commands
UI A Run Cleanup Now button on the cleanup page.

Deletion History Config

Every cleanup operation (manual, scheduled, CLI, dry-run) is recorded in an append-only JSON file:

Each entry captures: timestamp, trigger (schedule/cli/ui/manual), operation type, deleted count + breakdown, duration, table state before/after (rows + size MB), config snapshot, and user/IP context. Empty operations (0 rows deleted) are skipped.

The package automatically creates the storage directory and a .gitignore to prevent committing the JSON file.

Usage

Auto-Logging

Once installed, all Eloquent model events are logged automatically:

To exclude specific models:

Enrichment payload

Every activity log entry โ€” whether from auto-logging, the LogsActivity trait, or manual activity() calls โ€” is enriched with contextual data:

Example enriched properties

Browse UI

Visit /activity-log (or your configured prefix). Top navigation includes: Activity Log, Statistics, Cleanup, Deletion History, About โ€” plus a language switcher, theme toggle, and (when password gate is on) logout.

The list view provides:

Attribute translation

Attribute names (column names like first_name, email_verified_at) are auto-translated using lang/{locale}/validation.php:

Define translations once and they appear everywhere in the UI:

Statistics Dashboard

Visit /activity-log/statistics. Each section loads independently via AJAX with skeleton states for fast initial render.

A date-range filter at the top applies to all sections (cached for 60s when filtered, 120s for all-time).

Sections: Overview cards ยท Peak Hour chart ยท Daily Activity (30 days) ยท Activity by Day of Week ยท Peak Times ยท Monthly Activity ยท System vs User Actions ยท Events Breakdown ยท Log Names ยท Top Models ยท Top Causers ยท Most Changed Attributes (last 1000 updates).

Deletion History Page

/activity-log/deletion-history โ€” auditable record of every cleanup operation:

Artisan Commands

The prune command is automatically registered with the Laravel scheduler when retention.schedule is set (and you have schedule:work or cron running).

Localization

The package ships with English and Arabic translations. The UI auto-adapts to RTL when locale is ar.

Or at runtime:

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

To customize translations:

This copies the files to lang/vendor/activitylog-browse/ where you can edit them or add new languages โ€” then update available_locales in the config.

Multi-Tenancy

Works out of the box with stancl/tenancy (multi-database tenancy):

Setup for multi-database tenancy

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

  2. Publish migrations to your tenant migration path:

    Then move them to database/migrations/tenant/ (or wherever your tenant migrations live).

  3. Add tenancy middleware to the browse routes:

Without tenancy, no extra setup is needed โ€” everything works as expected.

Performance Notes

The package is designed for low-overhead operation even on high-traffic apps with auto-logging enabled:

For best results on high-throughput apps:

Architecture

Component Role
ActivitylogBrowseServiceProvider Registers everything: listener, observer, routes, scheduler
GlobalModelLogger Listens to global Eloquent events; logs activity for models without LogsActivity
ActivityEnrichmentObserver Observes the Activity model's creating event; merges enrichment data into properties
RequestDataCollector / DeviceDataCollector / ... Individual data collectors invoked by the observer
RelationDiscovery Reflection-based auto-discovery of Eloquent relationships for related-model browsing
RetentionPruner Implements the priority hierarchy โ€” age, size, per-model, per-log-name pruning
DeletionLogger Writes deletion entries to the JSON history file with size/count caps
ActivityLogHelpers Shared helpers โ€” connection name, table size, cache key prefix, stats cache invalidation
ActivityLogController Handles the browse UI: filtering, AJAX endpoints, statistics API, attribute inspection, cleanup, deletion history
RequirePassword middleware Enforces the optional password gate (rate-limited login)
SetLocale middleware Applies the user's locale preference from the session
InstallCommand activitylog-browse:install โ€” publishes assets, fixes UUID columns, adds indexes
PruneCommand activitylog-browse:prune โ€” manual / scheduled retention runs

License

MIT โ€” see LICENSE.


All versions of spatie-activitylog-browse with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
spatie/laravel-activitylog Version ^4.0
illuminate/support Version ^10.0||^11.0||^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mahmoud-mhamed/spatie-activitylog-browse contains the following files

Loading the files please wait ...