maatify/event-logging 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maatify/event-logging

Composer 安装命令:

composer require maatify/event-logging

包简介

Framework-agnostic standalone event logging library containing isolated Maatify logging domains. Depends only on explicit Composer/runtime dependencies.

README 文档

README

Maatify.dev

Latest Version PHP Version License

PHPStan

Changelog Security

Monthly Downloads Total Downloads

maatify/event-logging is a framework-agnostic standalone Composer package for registering event logging domains within the Maatify ecosystem.

This package provides strict domain isolation, MySQL persistence, and fail-open/fail-closed semantics without mandatory framework bindings. It intentionally relies on explicit Composer and runtime dependencies to operate autonomously from host applications and frameworks.

🚀 Key Features

  • Six Isolated Logging Domains: Explicit boundaries for audit, tracing, signals, and operations.
  • Domain-Specific Recorders: Tailored commands, DTOs, and repositories per domain.
  • MySQL-Only Persistence: Direct database persistence through domain-owned repositories.
  • AuthoritativeAudit Semantics: Fail-closed governance logging.
  • Fail-Open Boundaries: Non-authoritative domains can accept a PSR-3 fallback logger.
  • Optional Framework-Agnostic Provider and Bindings: Built-in optional factories and pure-PHP DI binding helpers for wiring dependencies.
  • Primitive Cursor-Based Read APIs: Dedicated, stable read/query capabilities.
  • No Mandatory Framework Bindings: Optional bindings are pure PHP convenience helpers and do not add framework runtime dependencies.
  • No Generic Logging API: Excludes shared generic loggers, generic log tables, or unified repositories.

📋 Requirements

  • PHP ^8.2
  • ext-json
  • ext-pdo

Composer/Runtime Dependencies:

  • psr/log
  • ramsey/uuid
  • maatify/exceptions
  • maatify/shared-common

📦 Installation

composer require maatify/event-logging

📖 Usage

Factory / Provider Wiring

Host applications provide their own dependencies (PDO, Clock, PSR-3 Logger) to instantiate the domain provider:

use Maatify\EventLogging\Provider\EventLoggingProviderFactory;
use Maatify\EventLogging\Common\SystemClock;

$pdo = new \PDO('mysql:host=localhost;dbname=mydb', 'user', 'pass');
$clock = new SystemClock();
$psrLogger = new \Monolog\Logger('event-logging-fallback'); // Optional for fail-open domains

// Create the provider service map
$provider = EventLoggingProviderFactory::createDefault($pdo, $clock, $psrLogger);

// Typed accessors enforce strict domain API boundaries
$auditTrail = $provider->auditTrail();

(See 01-factory-provider.php for manual factory/provider wiring. Hosts that prefer DI can also import the optional pure-PHP Maatify\EventLogging\Bootstrap\EventLoggingBindings::definitions() helper; this helper is not required and does not introduce framework-specific behavior.)

Domain Recorder Usage

Recording an authoritative audit (fail-closed, requires robust persistence):

$authoritativeAudit = $provider->authoritativeAudit();

// Using the primitive convenience record method
$authoritativeAudit->record(
    action: 'update_permissions',
    targetType: 'user',
    targetId: 123,
    riskLevel: 'HIGH',
    actorType: 'admin',
    actorId: 1,
    payload: ['role' => 'superuser'],
    correlationId: 'abc-123'
);

(See 03-authoritative-audit-record.php and 04-audit-trail-record.php for broader examples.)

🏗️ Logging Domains

The package maintains six separated event domains:

  1. AuthoritativeAudit — Governance/security posture logging with fail-closed semantics.
  2. AuditTrail — Reads, views, exports, and navigation visibility events.
  3. SecuritySignals — Authentication and security anomaly signals.
  4. BehaviorTrace — Operational activity and mutation-only behavior events.
  5. DiagnosticsTelemetry — Technical observability and diagnostic events.
  6. DeliveryOperations — Async jobs, notifications, webhooks, and delivery lifecycle events.

🛡️ Architecture Guarantees

  • Framework-Agnostic: Operates without any dependency on external framework containers or routes.
  • Standalone Execution: Complete isolation from host application codebases.
  • Domain Isolation: Every logging domain has exclusive ownership over its DTOs, tables, and policies.
  • Host-Provided PDO: Database connections must be injected; the package does not manage connection lifecycles.
  • MySQL-Only: Relies purely on MySQL schema without SQLite fallback support.
  • Explicit Dependencies Only: Avoids zero-dependency assumptions; explicit runtime requirements ensure robustness.
  • No Generic Paradigms: The package does not expose a catch-all logger, generic recorder, generic repository, or shared generic log table. PSR-3 is used only as an optional fallback logger for fail-open domains.

🧪 Examples

The examples/ directory contains plain PHP illustrative skeletons covering integration scenarios. See the Examples Coverage Plan for full context.

📚 Documentation

Integration Guides

✅ Quality Status

  • PHP 8.2+
  • PHPStan Level Max
  • PHPUnit testing available
  • GitHub Actions CI validated

🪪 License

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

👤 Author

Engineered by Mohamed Abdulalim (@megyptm)
Backend Lead & Technical Architect
https://www.maatify.dev

[Built with ❤️ by Maatify.dev — Unified Ecosystem for Modern PHP Libraries]

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固