PHPackages                             azaharizaman/nexus-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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. azaharizaman/nexus-audit-logger

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

azaharizaman/nexus-audit-logger
===============================

Framework-agnostic audit logging package for tracking CRUD operations and system activities

v0.1.0-alpha1(1mo ago)024MITPHPPHP ^8.2

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-audit-logger)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-audit-logger)[ RSS](/packages/azaharizaman-nexus-audit-logger/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (2)Versions (2)Used By (4)

Nexus AuditLogger
=================

[](#nexus-auditlogger)

A framework-agnostic audit logging package for tracking CRUD operations, system activities, and user actions with comprehensive retention policies and filtering capabilities.

Features
--------

[](#features)

- **Automatic CRUD Tracking**: Capture create, read, update, delete operations
- **Before/After State**: Record model state changes for updates
- **User Context**: Track who performed actions with IP, user agent, timestamp
- **Audit Levels**: Low (1), Medium (2), High (3), Critical (4) for risk-based filtering
- **Batch Operations**: Group related activities with UUID
- **Retention Policies**: Configurable retention with automatic purging
- **Tenant Isolation**: Multi-tenant support with data isolation
- **Search &amp; Filter**: Full-text search, date range, entity type filtering
- **Export**: CSV, JSON, PDF export capabilities
- **Sensitive Data Masking**: Automatic masking of passwords, tokens, secrets
- **Asynchronous Logging**: Queue-based logging to prevent performance impact
- **Event-Driven**: Notifications for high-value activities

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

[](#installation)

```
composer require azaharizaman/nexus-audit-logger:"*@dev"
```

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

[](#architecture)

This package follows the Nexus architecture pattern:

- **Pure PHP**: No Laravel dependencies in core services
- **Contract-Driven**: All persistence via interfaces
- **Framework-Agnostic**: Can be used in any PHP application

Package Structure
-----------------

[](#package-structure)

```
packages/AuditLogger/
├── composer.json
├── README.md
├── LICENSE
└── src/
    ├── Contracts/              # Interfaces
    │   ├── AuditLogInterface.php
    │   ├── AuditLogRepositoryInterface.php
    │   └── AuditConfigInterface.php
    ├── Exceptions/             # Domain exceptions
    │   ├── AuditLogNotFoundException.php
    │   ├── InvalidAuditLevelException.php
    │   └── InvalidRetentionPolicyException.php
    ├── Services/               # Business logic
    │   ├── AuditLogManager.php
    │   ├── AuditLogSearchService.php
    │   ├── AuditLogExportService.php
    │   ├── RetentionPolicyService.php
    │   └── SensitiveDataMasker.php
    ├── ValueObjects/           # Immutable value objects
    │   ├── AuditLevel.php
    │   └── RetentionPolicy.php
    └── AuditLoggerServiceProvider.php  # Optional Laravel integration

```

Usage
-----

[](#usage)

### Define Repository Implementation

[](#define-repository-implementation)

In your application layer (e.g., Laravel), implement the repository interface:

```
use Nexus\AuditLogger\Contracts\AuditLogRepositoryInterface;

class DbAuditLogRepository implements AuditLogRepositoryInterface
{
    // Implement all contract methods using your persistence layer
}
```

### Log Activities

[](#log-activities)

```
use Nexus\AuditLogger\Services\AuditLogManager;

$auditManager = new AuditLogManager($repository, $config);

$auditManager->log(
    logName: 'user_update',
    description: 'User profile updated',
    subjectType: 'User',
    subjectId: 123,
    causerType: 'User',
    causerId: 456,
    properties: ['old' => [...], 'new' => [...]],
    level: 3, // High
    batchUuid: 'uuid-here'
);
```

### Search Logs

[](#search-logs)

```
$searchService = new AuditLogSearchService($repository);

$logs = $searchService->search([
    'date_from' => '2025-01-01',
    'date_to' => '2025-12-31',
    'causer_id' => 456,
    'subject_type' => 'User',
    'level' => 4, // Critical
    'log_name' => 'user_update'
]);
```

### Export Logs

[](#export-logs)

```
$exportService = new AuditLogExportService($repository);

$csv = $exportService->exportToCsv($filters);
$json = $exportService->exportToJson($filters);
$pdf = $exportService->exportToPdf($filters);
```

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

[](#requirements)

See `REQUIREMENTS.csv` for complete list of architectural, business, and functional requirements.

### Key Requirements

[](#key-requirements)

- **ARC-AUD-0001**: Framework-agnostic with no Laravel dependencies
- **ARC-AUD-0002**: All data structures via interfaces
- **BUS-AUD-0145**: Logs must include log\_name, description, timestamp
- **BUS-AUD-0146**: Audit levels: 1 (Low), 2 (Medium), 3 (High), 4 (Critical)
- **BUS-AUD-0147**: Default retention 90 days
- **FUN-AUD-0185**: Automatic CRUD capture
- **FUN-AUD-0192**: Automatic sensitive data masking

Implementation in Atomy
-----------------------

[](#implementation-in-atomy)

To use in Laravel (Atomy app):

1. Create migration for `audit_logs` table
2. Create Eloquent model implementing `AuditLogInterface`
3. Create repository implementing `AuditLogRepositoryInterface`
4. Bind contracts in service provider
5. Create audit trait for models
6. Register API endpoints

See `apps/Atomy/` for implementation examples.

Documentation
-------------

[](#documentation)

### Quick Links

[](#quick-links)

- **[Getting Started Guide](docs/getting-started.md)** - Installation and basic configuration
- **[API Reference](docs/api-reference.md)** - Complete API documentation
- **[Integration Guide](docs/integration-guide.md)** - Laravel and Symfony integration examples
- **[Examples](docs/examples/)** - Runnable code examples

### Package Documentation

[](#package-documentation)

- **[Requirements](REQUIREMENTS.md)** - Comprehensive requirements traceability
- **[Implementation Summary](IMPLEMENTATION_SUMMARY.md)** - Package structure and metrics
- **[Test Suite Summary](TEST_SUITE_SUMMARY.md)** - Test coverage and strategy
- **[Valuation Matrix](VALUATION_MATRIX.md)** - Package valuation and ROI analysis

### Additional Resources

[](#additional-resources)

- **Package Overview**: User-friendly audit logging for CRUD tracking and compliance
- **Key Differentiator**: Search/export/retention focus vs Nexus\\Audit's cryptographic verification
- **Total Files**: 14 PHP files, 1,363 lines of code
- **Test Coverage**: 58 tests planned (unit, integration, feature)
- **Package Value**: $65,000 (158% ROI, compliance infrastructure)

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

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

36d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k240.0M312](/packages/sentry-sentry)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.0M597](/packages/illuminate-log)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M180](/packages/api-platform-metadata)[pagemachine/typo3-formlog

Form log for TYPO3

23233.9k7](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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