mahedulhasan/audit-logger

There is no license information available for the latest version (v1.0.0) of this package.

Laravel Audit Logging Package

Maintainers

Package info

github.com/ripuhasan/audit-logger

pkg:composer/mahedulhasan/audit-logger

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2025-10-23 21:02 UTC

This package is auto-updated.

Last update: 2026-03-25 19:52:54 UTC


README

A simple Laravel Audit Logging Package to track database changes on your models. Tracks create, update, delete events and stores only the changed fields in audit_logs table.

Features

  • Logs created, updated, and deleted events automatically
  • Only stores changed fields (old_values & new_values) on updates
  • Tracks which user made the changes
  • Stores client IP address
  • Dynamic observer attachment for all or selected models
  • Bootstrap-based view to display audit logs
  • Easy to integrate as a Laravel package

Requirements

  • Laravel 9 / 10
  • PHP >= 8.1
  • MySQL or any database supported by Laravel

Installation

Require the package via Composer:

composer require mahedulhasan/audit-logger

Make sure your minimum-stability in composer.json allows dev packages if needed:

"minimum-stability": "dev",
"prefer-stable": true

Run the migrations:

php artisan migrate

(Optional) Publish views/config if you want to customize:

php artisan vendor:publish --provider="MahedulHasan\AuditLogger\AuditLoggerServiceProvider"

Development Version (GitHub)

If you want to use the latest development version, install directly from GitHub:

  1. Add the VCS repository to your project's composer.json:
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/ripuhasan/audit-logger"
    }
]
  1. Require the dev-main branch:
composer require mahedulhasan/audit-logger:dev-main

Usage

Observer

The package automatically attaches AuditObserver to your models. To attach manually:

use App\Models\User;
use MahedulHasan\AuditLogger\Observers\AuditObserver;

User::observe(AuditObserver::class);

Display Audit Logs

Visit the route:

/audit-logs

This route displays a Bootstrap table showing:

  • User
  • Event (Created / Updated / Deleted)
  • Model & ID
  • Changed fields (old → new)
  • IP Address
  • Timestamp

Note: The route is automatically registered by the package's ServiceProvider.

Development

  • Add new migrations in database/migrations/
  • Add additional observers in src/Observers/
  • Update views in resources/views/
  • Run composer dump-autoload if you add new namespaces

Notes

  • No local installation needed. The package can be installed directly via Composer.
  • Ensure ServiceProvider is registered automatically via extra.laravel.providers in composer.json.
  • Migrations, routes, and views are loaded automatically. You only need to run php artisan migrate.

License

MIT License © [Mahedul Hasan]