laravel-chronicle/core
Chronicle provides cryptographically verifiable audit logging for Laravel. It records events in an append-only, hash-chained ledger to make tampering detectable, with features like verifiable exports, signed checkpoints, key rotation, and external anchoring.
Chronicle is a cryptographically verifiable audit logging solution designed for Laravel, addressing critical use cases like security logging, financial compliance, and forensic analysis. Its append-only ledger with hash chaining ensures tamper-proof audit trails, making it ideal for systems requiring immutable, verifiable records (e.g., regulatory compliance, fraud detection, or operational observability).
Key architectural strengths:
Fit for: ✅ High-assurance audit trails (e.g., financial systems, healthcare, legal compliance). ✅ Post-mortem forensics (e.g., security incidents, fraud investigations). ✅ Regulatory reporting (e.g., GDPR, SOX, PCI-DSS). ✅ Operational observability (e.g., tracking critical system changes).
Not ideal for:
❌ High-throughput, low-latency logging (hash chaining adds computational overhead per entry).
❌ Systems where audit logs are rarely queried (overkill for simple debugging logs).
❌ Environments without PHP 8.2+ or Laravel 12/13 (hard dependency on ext-sodium/ext-openssl).
Chronicle integrates seamlessly into Laravel via:
HasChronicle) for automatic model auditing.chronicle:checkpoint, chronicle:verify).Database Schema:
chronicle_entries, chronicle_checkpoints) with indexes for performance.chronicle:install handles setup).Dependencies:
ext-sodium, ext-openssl.Compatibility Risks:
| Risk Area | Mitigation Strategy |
|---|---|
| Performance Overhead | Benchmark hash chaining latency; consider batch recording for high-volume systems. |
| Key Management | Use HSM/KMS (e.g., AWS KMS adapter) to avoid private keys in code. |
| External Anchoring | Test TSA/S3 anchoring in staging; monitor failure rates. |
| Schema Changes | Run chronicle:install --migrate in a staging environment first. |
| Verification Cost | Use incremental verification (--since-last-checkpoint) for large ledgers. |
| ULID Generation | Ensure clock synchronization (ULIDs require monotonic time). |
| Custom Providers | Extend SigningProvider/AnchoringProvider interfaces for non-standard setups. |
Critical Path Risks:
private_key securely).Compliance Requirements:
Performance Constraints:
Key Management:
Operational Workflow:
Disaster Recovery:
Legacy Integration:
Cost Implications:
Chronicle is optimized for Laravel but can be adapted for PHP-based monoliths with minor adjustments. Key compatibility factors:
| Component | Fit Level | Notes |
|---|---|---|
| Laravel 12/13 | Native | Full feature support (Eloquent, Facades, Artisan). |
| PHP 8.2+ | Required | Uses typed properties, attributes, and modern PHP features. |
| Eloquent Models | Native | HasChronicle trait integrates seamlessly. |
| Queue Workers | Recommended | Offloads hash chaining/computation for high-volume systems. |
| Custom PHP Apps | Partial | Requires manual setup of database migrations, signing keys, and event dispatching. |
| Microservices | Limited | Shared ledger requires consistent database access (not ideal for distributed writes). |
Recommended Stack:
| Phase | Steps | Tools/Commands |
|---|---|---|
| Preparation | 1. Assess compliance/audit requirements. | Review docs, stakeholder alignment. |
| 2. Benchmark performance with expected load. | Load test with Chronicle::record(). |
|
| 3. Design key management strategy (HSM/KMS vs. local keys). | chronicle:key:generate. |
|
| Installation | 4. Add laravel-chronicle/core to composer.json. |
composer require. |
5. Run php artisan chronicle:install --migrate. |
Migration setup. | |
6. Configure config/chronicle.php (keys, anchoring, retention). |
Manual edit. | |
| Pilot | 7. Enable HasChronicle on non-critical models first. |
Trait addition. |
| 8. Test manual recording for custom events. | Chronicle::record()->...->commit(). |
|
9. Verify ledger integrity with chronicle:verify. |
Artisan command. | |
| Rollout | 10. Gradually add HasChronicle to core models. |
Trait addition. |
| 11. Set up automated checkpoints (e.g., cron job). | php artisan chronicle:checkpoint. |
|
| 12. Enable external anchoring (if required). | Configure anchoring in config. |
|
| **Optimization |
How can I help you explore Laravel packages today?