PHPackages                             mblsolutions/audit-logging - 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. mblsolutions/audit-logging

ActivePackage

mblsolutions/audit-logging
==========================

Audit Logging package for Laravel applications

v2.0.0(2mo ago)04.7k↑250.8%1proprietaryPHPPHP ^8.2CI passing

Since Sep 6Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/mblsolutions/audit-logging)[ Packagist](https://packagist.org/packages/mblsolutions/audit-logging)[ RSS](/packages/mblsolutions-audit-logging/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (8)Versions (17)Used By (0)

Audit Logging
=============

[](#audit-logging)

Audit Logging for Laravel projects

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

[](#installation)

The recommended method to install LaravelRepository is with composer

```
php composer require mblsolutions/audit-logging
```

### Laravel without auto-discovery

[](#laravel-without-auto-discovery)

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

```
\MBLSolutions\AuditLogging\AuditLoggingServiceProvider::class,
```

### Package configuration

[](#package-configuration)

```
Copy the package configuration to your local config directory.
```

```
php artisan vendor:publish --tag=audit-logging-config
```

### Database Driver

[](#database-driver)

If you would like to use the Database driver to store your audit logs, you will first need to create and run the database driver migration.

```
php artisan audit:database:table
```

This will create a new migration in `database/migrations`, after creating this migration run the database migrations to create the new table.

```
php artisan migrate
```

Usage
-----

[](#usage)

The configuration and setup can be adjusted in the audit logging config file located in `config/audit-logging.php`. We recommend reading through the config file before enabling audit logging to ensure you have the optimum setup.

### Enable/Disable Logging

[](#enabledisable-logging)

Before logs are stored you will need to enable audit logging by setting the config values to true.

```
// Request Audit Logging
'enabled' => env('AUDIT_LOGGING_ENABLED', false),

// Event Audit Logging
'event_enabled' => env('EVENT_AUDIT_LOGGING_ENABLED', true)
```

This can also be set in your .env file by using the corresponding environment variable

```
AUDIT_LOGGING_ENABLED=true
EVENT_AUDIT_LOGGING_ENABLED=false
```

### Enable/Disable extra logging information

[](#enabledisable-extra-logging-information)

From version 1.6.1, you could specify what extra column is needed to keep the application free from database migration on existing database schema in newer version.

```
// Disable the extra logging information
'extra_column' => null
// OR Enable the extra logging information
// Define an array of extra logging information for new database column from RequestResponseDTO property
'extra_column' => [
    'user_id' => 'userId'
]
```

### Audit Logging Middleware

[](#audit-logging-middleware)

To enable audit logging for routes there are multiple ways this can be achieved, middleware aliases has been created

- `web-audit-logging`
- `api-audit-logging`
- `console-audit-logging`

The only differences with these middleware are the log type

#### Single Route

[](#single-route)

You can enable audit logging for a single route by applying the middleware to the route.

```
use Illuminate\Routing\Route;

Route::get('/user', function () {
    //
})->middleware('web-audit-logging');
```

Or by using the fully qualified class name

```
use Illuminate\Routing\Route;
use MBLSolutions\AuditLogging\Http\Middleware\AuditLogging;

Route::get('/user', function () {
    //
})->middleware(AuditLogging::class);
```

#### Route Groups

[](#route-groups)

You can apply the middleware to a group of routes.

```
use Illuminate\Routing\Route;

Route::middleware(['web-audit-logging'])->group(function () {

    Route::get('/', function () {
        //
    });

    Route::get('/user', function () {
        //
    });

});
```

#### Excluding Routes

[](#excluding-routes)

You can exclude specific routes in a group of middleware.

```
use Illuminate\Routing\Route;

Route::middleware(['api-audit-logging'])->group(function () {

    Route::get('/', function () {
        //
    })->withoutMiddleware(['api-audit-logging']);

    Route::get('/user', function () {
        //
    });

});
```

### Optional Model/Trait for Log Retrieval

[](#optional-modeltrait-for-log-retrieval)

We have included an AuditLog Model with a BindsDynamically trait which you can use if you'd like to use an eloquent model for retrieving and formatting data.

- **MBLSolutions\\AuditLogging\\Models\\AuditLog** - Implements BindsDynamically trait. Can be extended if needed.
- **MBLSolutions\\AuditLogging\\Traids\\BindsDynamically** - Can be used in custom model or automatically as above.

#### Using Model with BindsDynamically trait

[](#using-model-with-bindsdynamically-trait)

In order to use the AuditLog model (or any model implementing the BindsDynamically trait) you need to instantiate it with a connection and table as in the example below:

```
$config = config('audit-logging.drivers.database');

$auditLog = new MBLSolutions\AuditLogging\Models\AuditLog;
$auditLog->setConnection($config['connection']);
$auditLog->setTable($config['table']);
```

You can then use the `$auditLog` as you would any eloquent model.

#### Archiving Logs

[](#archiving-logs)

If you would like to archive your logs and continue with a fresh table then you can use the archive command by running:

```
php artisan audit:database:archive
```

If you have installed fresh from version 1.6.0 you are good to go, otherwise if you have an existing installation from an earlier version you should run the update migration to add an index to the audit logs created\_at column (if you have not already). You just need to publish the update with:

```
php artisan audit:update:addindex
```

and then remember to run

```
php artisan migrate
```

This should be done as soon as possible after your archiving as the more data in the table the longer the migration will take.

License
-------

[](#license)

Audit Logging is free software distributed under the terms of the MIT license.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance91

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~182 days

Total

10

Last Release

73d ago

Major Versions

v1.6.1 → v2.0.02026-02-24

PHP version history (3 changes)v1.0.0PHP ^7.4|^8.0|^8.1

v1.6.1PHP ^8.1|^8.2

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/610936?v=4)[Christian Innerbichler](/maintainers/lerouse)[@lerouse](https://github.com/lerouse)

![](https://www.gravatar.com/avatar/102e5b958c4a1e833fd8812ac866581ccf52bbc0cd9627253589025c42cf0f37?d=identicon)[hayleyberryl2s](/maintainers/hayleyberryl2s)

---

Top Contributors

[![rsloan-mlbsolutions](https://avatars.githubusercontent.com/u/115983535?v=4)](https://github.com/rsloan-mlbsolutions "rsloan-mlbsolutions (17 commits)")[![lerouse](https://avatars.githubusercontent.com/u/610936?v=4)](https://github.com/lerouse "lerouse (12 commits)")[![hayleyberryl2s](https://avatars.githubusercontent.com/u/152175725?v=4)](https://github.com/hayleyberryl2s "hayleyberryl2s (8 commits)")[![chun-yu-tang](https://avatars.githubusercontent.com/u/173277897?v=4)](https://github.com/chun-yu-tang "chun-yu-tang (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mblsolutions-audit-logging/health.svg)

```
[![Health](https://phpackages.com/badges/mblsolutions-audit-logging/health.svg)](https://phpackages.com/packages/mblsolutions-audit-logging)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[watson/validating

Eloquent model validating trait.

9723.3M46](/packages/watson-validating)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-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.

44643.1k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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