{"id":48837702,"url":"https://github.com/marcstraube/zappzarapp-php-audit-logger","last_synced_at":"2026-04-15T00:05:17.822Z","repository":{"id":338695560,"uuid":"1158786771","full_name":"marcstraube/zappzarapp-php-audit-logger","owner":"marcstraube","description":"GDPR-compliant audit logging for PHP with injectable encryption, configurable storage, and tamper-proof checksums.","archived":false,"fork":false,"pushed_at":"2026-04-11T12:15:36.000Z","size":275,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-11T12:15:48.496Z","etag":null,"topics":["audit-log","encryption","gdpr","php","security"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcstraube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-15T22:54:03.000Z","updated_at":"2026-04-11T11:37:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/marcstraube/zappzarapp-php-audit-logger","commit_stats":null,"previous_names":["marcstraube/zappzarapp-php-audit-logger"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marcstraube/zappzarapp-php-audit-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcstraube%2Fzappzarapp-php-audit-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcstraube%2Fzappzarapp-php-audit-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcstraube%2Fzappzarapp-php-audit-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcstraube%2Fzappzarapp-php-audit-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcstraube","download_url":"https://codeload.github.com/marcstraube/zappzarapp-php-audit-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcstraube%2Fzappzarapp-php-audit-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31820370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audit-log","encryption","gdpr","php","security"],"created_at":"2026-04-15T00:05:16.606Z","updated_at":"2026-04-15T00:05:17.806Z","avatar_url":"https://github.com/marcstraube.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zappzarapp/audit-logger\n\nGDPR-compliant audit logging for PHP with injectable encryption, configurable\nstorage, and tamper-proof checksums.\n\n## Features\n\n- **GDPR compliant** - Supports Art. 15, 17, 30, 32, 33\n- **Injectable encryption** - AppEncryption (AES-256-GCM) or DatabaseEncryption\n- **Tamper-proof** - HMAC-SHA-256 checksums with `verify()` method\n- **Configurable** - Custom table name, optional file logging\n- **Null Object** - `NullAuditLogger` for environments without audit requirements\n- **Zero dependencies** - Only requires `ext-pdo` (stdlib)\n- **Both PostgreSQL and MariaDB** - Migration SQL included\n\n## Installation\n\n```bash\ncomposer require zappzarapp/audit-logger\n```\n\n## Quick Start\n\n```php\nuse Zappzarapp\\AuditLogger\\AuditLogger;\nuse Zappzarapp\\AuditLogger\\AuditLogEntry;\n\n$auditLogger = new AuditLogger(\n    pdo: $pdo,\n    encryptionKey: $_ENV['ENCRYPTION_KEY'],\n);\n\n// Log a data access event\n$auditLogger-\u003elog(new AuditLogEntry(\n    action: 'user.view',\n    entityType: 'user',\n    entityId: 123,\n    userId: $currentUserId,\n    ipAddress: $request-\u003egetClientIp(),\n    userAgent: $request-\u003egetUserAgent(),\n));\n\n// Log authentication\n$auditLogger-\u003elogAuth(\n    action: 'login.success',\n    userId: $userId,\n    ipAddress: $request-\u003egetClientIp(),\n    userAgent: $request-\u003egetUserAgent(),\n);\n\n// Log admin action\n$auditLogger-\u003elogAdmin(\n    action: 'role.granted',\n    adminUserId: $adminId,\n    entityType: 'user',\n    entityId: $targetUserId,\n    data: ['role' =\u003e 'moderator'],\n);\n\n// Query logs\n$logs = $auditLogger-\u003egetLogsForEntity('user', 123);\n$userLogs = $auditLogger-\u003egetLogsForUser($userId);\n\n// Verify integrity\nforeach ($logs as $log) {\n    if (!$auditLogger-\u003everify($log)) {\n        // Tampered entry detected!\n    }\n}\n```\n\n## Configuration\n\n```php\nuse Zappzarapp\\AuditLogger\\AuditLogger;\nuse Zappzarapp\\AuditLogger\\Encryption\\AppEncryption;\nuse Zappzarapp\\AuditLogger\\Encryption\\DatabaseEncryption;\n\n// Full configuration\n$auditLogger = new AuditLogger(\n    pdo: $pdo,\n    encryptionKey: $_ENV['ENCRYPTION_KEY'],\n    encryption: new AppEncryption(),    // default (AES-256-GCM in PHP)\n    tableName: 'audit_logs',            // default table name\n    logFilePath: '/var/log/audit.log',  // optional file logging (null = disabled)\n);\n\n// Using database-level encryption (for existing encrypt_text() setups)\n$auditLogger = new AuditLogger(\n    pdo: $pdo,\n    encryptionKey: $_ENV['ENCRYPTION_KEY'],\n    encryption: new DatabaseEncryption(),\n);\n\n// Disable audit logging (Null Object pattern)\n$auditLogger = new NullAuditLogger();\n```\n\n\u003e **Note:** File logging (`logFilePath`) does not include log rotation. Configure\n\u003e external rotation (e.g. `logrotate`) to prevent unbounded file growth.\n\u003e\n\u003e Example `/etc/logrotate.d/audit-logger`:\n\u003e\n\u003e ```text\n\u003e /var/log/audit.log {\n\u003e     daily\n\u003e     rotate 90\n\u003e     compress\n\u003e     delaycompress\n\u003e     missingok\n\u003e     notifempty\n\u003e     copytruncate\n\u003e }\n\u003e ```\n\n\u003e **Note:** The library does not set query timeouts on the injected PDO connection.\n\u003e Configure timeouts at the connection level to prevent indefinite blocking:\n\u003e\n\u003e ```php\n\u003e // PostgreSQL\n\u003e $pdo-\u003eexec('SET statement_timeout = 5000'); // 5 seconds\n\u003e\n\u003e // MariaDB / MySQL\n\u003e $pdo = new PDO($dsn, $user, $pass, [\n\u003e     PDO::ATTR_TIMEOUT =\u003e 5,\n\u003e ]);\n\u003e ```\n\n## Database Setup\n\nApply the migration for your database:\n\n- **PostgreSQL:** `migrations/postgresql/audit_logs.sql`\n- **MariaDB:** `migrations/mariadb/audit_logs.sql`\n\n## Documentation\n\n- [GDPR Compliance](docs/gdpr-compliance.md) - GDPR articles covered, purge/retention guidance\n- [Database Encryption](docs/database-encryption.md) - Migration from DB-level encryption\n\n## Development\n\n```bash\nmake install    # Install dependencies\nmake test       # Run tests\nmake analyse    # PHPStan static analysis\nmake cs-check   # Code style check\nmake check      # All quality checks\nmake check-full # Including mutation testing\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcstraube%2Fzappzarapp-php-audit-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcstraube%2Fzappzarapp-php-audit-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcstraube%2Fzappzarapp-php-audit-logger/lists"}