azaharizaman/nexus-audit-logger
Composer 安装命令:
composer require azaharizaman/nexus-audit-logger
包简介
Framework-agnostic audit logging package for tracking CRUD operations and system activities
README 文档
README
A framework-agnostic audit logging package for tracking CRUD operations, system activities, and user actions with comprehensive retention policies and filtering capabilities.
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 & 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
composer require azaharizaman/nexus-audit-logger:"*@dev"
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
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
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
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
$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
$exportService = new AuditLogExportService($repository); $csv = $exportService->exportToCsv($filters); $json = $exportService->exportToJson($filters); $pdf = $exportService->exportToPdf($filters);
Requirements
See REQUIREMENTS.csv for complete list of architectural, business, and functional 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
To use in Laravel (Atomy app):
- Create migration for
audit_logstable - Create Eloquent model implementing
AuditLogInterface - Create repository implementing
AuditLogRepositoryInterface - Bind contracts in service provider
- Create audit trait for models
- Register API endpoints
See apps/Atomy/ for implementation examples.
Documentation
Quick Links
- Getting Started Guide - Installation and basic configuration
- API Reference - Complete API documentation
- Integration Guide - Laravel and Symfony integration examples
- Examples - Runnable code examples
Package Documentation
- Requirements - Comprehensive requirements traceability
- Implementation Summary - Package structure and metrics
- Test Suite Summary - Test coverage and strategy
- Valuation Matrix - Package valuation and ROI analysis
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
composer test
License
MIT
azaharizaman/nexus-audit-logger 适用场景与选型建议
azaharizaman/nexus-audit-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 azaharizaman/nexus-audit-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 azaharizaman/nexus-audit-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 47
- 依赖项目数: 5
- 推荐数: 7
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-04