Download the PHP package infinitypaul/laravel-dynamodb-auditing without Composer
On this page you can find all versions of the php package infinitypaul/laravel-dynamodb-auditing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download infinitypaul/laravel-dynamodb-auditing
More information about infinitypaul/laravel-dynamodb-auditing
Files in infinitypaul/laravel-dynamodb-auditing
Package laravel-dynamodb-auditing
Short Description DynamoDB driver for Laravel Auditing package
License MIT
Informations about the package laravel-dynamodb-auditing
Laravel DynamoDB Auditing
A DynamoDB driver for the Laravel Auditing package, allowing you to store audit logs in AWS DynamoDB instead of a traditional database.
Features
- High Performance: Store audit logs in DynamoDB for better scalability
- Auto-scaling: DynamoDB handles scaling automatically
- TTL Support: Automatic cleanup of old audit logs
- Flexible Schema: NoSQL structure for varying audit data
- Query Service: Built-in service for querying audit logs
- Laravel Integration: Seamless integration with Laravel Auditing
- Queue Support: Optional queue processing for improved performance
Installation
1. Install via Composer
2. Publish Configuration
3. Configure Environment Variables
Add the following to your .env file:
4. Configure Laravel Auditing Driver
Add the DynamoDB driver configuration to your config/audit.php file in the drivers array:
5. Create DynamoDB Table
DynamoDB Table Structure
The package uses the following DynamoDB table structure:
Primary Key Design
- Partition Key (PK):
{auditable_type}#{auditable_id}(e.g.,App\Models\Wallet#12345) - Sort Key (SK):
{timestamp}#{audit_id}(for chronological ordering)
Global Secondary Index (GSI)
- CreatedAtIndex: For recent audit browsing
- Partition Key:
audit_type(always "AUDIT") - Sort Key:
created_at(timestamp)
Attributes
audit_id- Unique identifier for the audituser_id- ID of the user who performed the actionevent- Type of event (created, updated, deleted, etc.)auditable_type- Model class nameauditable_id- Model IDold_values- JSON of old valuesnew_values- JSON of new valuesurl- Request URLip_address- User's IP addressuser_agent- User's browser/clientcreated_at- TimestampTTL- Time-to-live for automatic cleanup
Setup
Quick Setup (Recommended)
The installer automatically:
- ✅ Checks for migration conflicts
- ✅ Publishes configuration
- ✅ Creates DynamoDB table with GSI
- ✅ Tests the installation
- ✅ Provides next steps
Manual Setup (Advanced)
If you prefer step-by-step control:
1. Create DynamoDB Table
2. Test the Setup
Usage
Basic Usage
Once configured, the package works automatically with Laravel Auditing:
Queue Processing (Recommended for Production)
For high-traffic applications, enable queue processing to improve performance:
Benefits of Queue Processing:
- Faster Response Times: Audit writes don't block user requests
- Better Scalability: Handle high-volume audit operations
- Resilience: Failed audit writes are automatically retried
- Non-blocking: User operations continue even if DynamoDB is temporarily unavailable
Queue Worker Setup:
Note: When queue processing is enabled, audit logs are processed asynchronously, so they may not be immediately available for querying.
Querying Audit Logs
Use the provided AuditQueryService:
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
AUDIT_DRIVER |
Audit driver to use | database |
DYNAMODB_AUDIT_TABLE |
DynamoDB table name | your-audit-logs |
DYNAMODB_AUDIT_TTL_DAYS |
Days before auto-deletion (null = infinite) | 730 |
DYNAMODB_AUDIT_RECENT_DAYS |
Days to look back for recent audit browsing | 1 |
DYNAMODB_AUDIT_QUEUE_ENABLED |
Enable queue processing for better performance | false |
DYNAMODB_AUDIT_QUEUE_CONNECTION |
Queue connection to use (null = use default) | null |
DYNAMODB_AUDIT_QUEUE_NAME |
Queue name for audit jobs (null = use default) | null |
DYNAMODB_ENDPOINT |
Local DynamoDB endpoint | null |
AWS_ACCESS_KEY_ID |
AWS access key | Required for production |
AWS_SECRET_ACCESS_KEY |
AWS secret key | Required for production |
AWS_DEFAULT_REGION |
AWS region | us-east-1 |
Configuration File
The config/dynamodb-auditing.php file allows you to customize:
- AWS credentials and region
- Table name and TTL settings
- Local vs production configurations
TTL (Time-To-Live) Configuration
Control automatic cleanup of audit logs:
Important: Setting DYNAMODB_AUDIT_TTL_DAYS=null will keep audit logs forever, which may increase storage costs over time.
Performance Considerations
Why DynamoDB for Audit Logs?
DynamoDB excels at audit log storage because:
- Consistent Performance: O(1) read/write operations regardless of table size
- Horizontal Scaling: Automatically scales to handle millions of records
- Efficient Queries: Partition + Sort key design enables fast lookups
- No Performance Degradation: Unlike SQL databases, performance doesn't degrade with table growth
Testing
Run the package tests:
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
Commands
The package provides several Artisan commands for setup and testing:
| Command | Description | Options |
|---|---|---|
audit:install-dynamodb |
🚀 Interactive installer - complete setup | --local, --production, --force |
audit:setup-dynamodb |
Create DynamoDB table with GSI for audit logs | --local, --force |
audit:test-dynamodb |
Test DynamoDB audit functionality | --model, --id |
audit:prevent-migration |
Remove conflicting MySQL audit migrations | --check |
Command Examples
Repository & Support
- 📦 GitHub Repository: https://github.com/infinitypaul/laravel-dynamodb-auditing
- 📚 Documentation: Available in the repository
- 🐛 Issues & Bug Reports: GitHub Issues
- 💬 Feature Requests: GitHub Issues
License
This package is open-sourced software licensed under the MIT license.
All versions of laravel-dynamodb-auditing with dependencies
laravel/framework Version ^10.0|^11.0|^12.0
owen-it/laravel-auditing Version ^13.0|^14.0
aws/aws-sdk-php Version ^3.0