grazulex / laravel-snapshot
A powerful Laravel package for tracking, storing and comparing snapshots of your Eloquent models — cleanly and safely.
                                    Fund package maintenance!
                                                                            
                                                                                                                                        Grazulex
                                                                                    
                                                                            
                                                                                                                                        Buy Me A Coffee
                                                                                    
                                                                            
                                                                                                                                        paypal.me/strauven
                                                                                    
                                                                
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 2
Open Issues: 0
pkg:composer/grazulex/laravel-snapshot
Requires
- php: ^8.3
 - illuminate/contracts: ^12.0
 - illuminate/support: ^12.19
 - nesbot/carbon: ^3.10
 - symfony/yaml: ^7.3
 
Requires (Dev)
- doctrine/dbal: ^4.2
 - larastan/larastan: ^3.4
 - laravel/pint: ^1.22
 - orchestra/testbench: ^10.0
 - pestphp/pest: ^3.8
 - pestphp/pest-plugin-laravel: ^3.2
 - rector/rector: ^2.0
 
Suggests
- doctrine/dbal: Required for database snapshot storage when using non-MySQL databases
 
README
  Advanced model versioning and snapshot system for Laravel applications
Overview
Laravel Snapshot is a powerful package for tracking, storing and comparing snapshots of your Eloquent models — cleanly and safely. Perfect for audit trails, data recovery, debugging, and version control of your Laravel applications.
✨ Features
- � Manual & Automatic Snapshots - Capture model state on demand or automatically
 - 🔄 Model Restoration - Restore models to any previous snapshot state
 - 📊 Smart Comparisons - Deep diff analysis between snapshots
 - 💾 Multiple Storage Backends - Database, file system, or in-memory storage
 - 📈 Rich Analytics - Statistics, change frequency, and trend analysis
 - ⚡ CLI Commands - Full command-line interface for all operations
 - 🧪 Testing Support - Built with Pest 3 and extensive test coverage
 - ✅ Production Ready - PHPStan level 5, optimized performance
 
� Quick Installation
# Install the package composer require grazulex/laravel-snapshot # Publish config (optional) php artisan vendor:publish --tag=snapshot-config # Run migrations php artisan migrate
� Documentation
All documentation, examples, and guides are now available in our comprehensive Wiki:
📚 Visit the Laravel Snapshot Wiki →
Quick Navigation:
| Topic | Link | 
|---|---|
| 🏁 Getting Started | Installation & Setup | 
| 📘 Basic Usage | Creating & Managing Snapshots | 
| ⚙️ Configuration | Configuration Options | 
| 🔄 Model Restoration | Restoring Previous States | 
| 📊 Analytics & Reports | Statistics & Analytics | 
| ⚡ CLI Commands | Command Reference | 
| 💡 Examples | Real-world Examples | 
| 🧪 Testing | Testing Your Implementation | 
| 🔧 Advanced Usage | Advanced Features | 
| 🚀 API Reference | Complete API Documentation | 
💡 Quick Example
use Grazulex\LaravelSnapshot\Traits\HasSnapshots; class Order extends Model { use HasSnapshots; } // Create snapshots $order = Order::find(1); $order->snapshot('before-discount'); $order->update(['total' => 99.99]); $order->snapshot('after-discount'); // Compare and restore $diff = $order->compareWithSnapshot('before-discount'); $order->restoreFromSnapshot('before-discount'); // CLI usage php artisan snapshot:save "App\Models\Order" --id=1 --label=backup php artisan snapshot:restore "App\Models\Order" 1 backup php artisan snapshot:diff before-discount after-discount
🎯 Use Cases
Perfect for:
- Financial Systems - Transaction history and audit trails
 - Content Management - Version control for articles and pages
 - E-commerce - Product and order change tracking
 - Data Recovery - Point-in-time data restoration
 - Compliance - Regulatory audit trail requirements
 - Debugging - Track state changes during development
 
🔧 Requirements
- PHP: ^8.3
 - Laravel: ^12.19
 - Carbon: ^3.10
 
🧪 Quality Assurance
- ✅ 95 Tests passing with Pest 3
 - ✅ PHPStan Level 5 compliance
 - ✅ 60%+ Code Coverage
 - ✅ Laravel Pint code style
 - ✅ Comprehensive CLI testing
 
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Commands
composer run-script full # Run all quality checks composer run-script test # Run tests composer run-script pint # Fix code style composer run-script phpstan # Static analysis
🔒 Security
If you discover a security vulnerability, please review our Security Policy.
📄 License
Laravel Snapshot is open-sourced software licensed under the MIT license.
📚 Complete Documentation | 💬 Discussions | � Issues
Made with ❤️ for the Laravel community