PHPackages                             iamjohndev/audit-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. [Security](/categories/security)
4. /
5. iamjohndev/audit-logger

ActiveLibrary[Security](/categories/security)

iamjohndev/audit-logger
=======================

Audit Logger is a simple PHP class that allows you to log user interactions in your application.

v1.1(3y ago)8182MITPHPPHP ^8.0

Since Apr 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/PseudoDevs/PHPAuditLogger)[ Packagist](https://packagist.org/packages/iamjohndev/audit-logger)[ RSS](/packages/iamjohndev-audit-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

AuditLogger
===========

[](#auditlogger)

Audit Logger is a simple PHP class that allows you to log user interactions in your application. You can configure the logging driver (file or database), database connection, and log formatter according to your needs.

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

[](#installation)

You can install Audit Logger using Composer by running the following command:

```
composer require iamjohndev/audit-logger
```

Replace your-vendor-name with your desired vendor name and your-package-name with the desired package name.

Usage
-----

[](#usage)

Include the Composer autoloader in your PHP files where you want to use the AuditLogger class:

`require_once 'vendor/autoload.php'; `

Set the log storage driver and the database connection (if using the database driver) before using the AuditLogger:

```
use iamjohndev\AuditLogger;

// Set the log storage driver
AuditLogger::setLogDriver('database');

// Set the database connection
$dbConnection = new mysqli('localhost', 'username', 'password', 'database_name');
AuditLogger::setDbConnection($dbConnection);
```

Set the log formatter (optional) if you want to customize the log entry format:

```
AuditLogger::setLogFormatter(function($userId, $action) {
    // Custom log formatting logic
    return "User ID: $userId | Action: $action";
});
```

Start logging user interactions by calling the **log** method:

```
// Log user interaction
$userId = 123;
$action = 'edit';
AuditLogger::log($userId, $action);
```

Retrieve all logs using the **getAllLogs** method:

```
// Get all logs
$logs = AuditLogger::getAllLogs();
print_r($logs);
```

Clear all logs using the **clearLogs** method:

```
// Clear all logs
AuditLogger::clearLogs();
```

### Database Configuration

[](#database-configuration)

If you're using the database log storage driver, make sure to configure the database connection by setting the appropriate values for the host, username, password, and database name in the database connection code:

```
$dbConnection = new mysqli('localhost', 'username', 'password', 'database_name');
```

Replace '**localhost**', '**username**', '**password**', and '**database\_name**' with the actual values for your database configuration.

#### Custom Logs Table (Optional)

[](#custom-logs-table-optional)

If you want to use a custom table name for storing logs in the database, you can set it using the setLogsTableName method:

```
AuditLogger::setLogsTableName('custom_logs_table');
```

```
CREATE TABLE custom_logs_table (
    id INT AUTO_INCREMENT PRIMARY KEY,
    timestamp DATETIME,
    user_id INT,
    action VARCHAR(255),
    module VARCHAR(255),
    log_entry TEXT
);
```

Replace '**custom\_logs\_table**' with the desired name for your custom logs table.

### License

[](#license)

This project is licensed under the MIT License. See the **LICENSE** file for details.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

1114d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac66619338aacab90850c8110820e48f5f9d52b917bf7eb317b4e15e63ef8cbc?d=identicon)[PseudoDevs](/maintainers/PseudoDevs)

---

Top Contributors

[![PseudoDevs](https://avatars.githubusercontent.com/u/28098260?v=4)](https://github.com/PseudoDevs "PseudoDevs (11 commits)")

---

Tags

audit-logaudit-trailencryptionphp

### Embed Badge

![Health badge](/badges/iamjohndev-audit-logger/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M212](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M112](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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