Download the PHP package eta/laravel-query-watcher without Composer
On this page you can find all versions of the php package eta/laravel-query-watcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eta/laravel-query-watcher
More information about eta/laravel-query-watcher
Files in eta/laravel-query-watcher
Package laravel-query-watcher
Short Description A Laravel package to monitor and log database queries with configurable thresholds
License MIT
Informations about the package laravel-query-watcher
Laravel Query Watcher
A Laravel package to monitor and log database queries with configurable thresholds and detailed performance metrics.
Features
- 🔍 Query Count Monitoring: Track the number of queries executed per request/command
- ⚡ Slow Query Detection: Identify queries that exceed execution time thresholds
- 🎯 Flexible Configuration: Customize thresholds, log levels, and channels
- 🚫 Path/Command Exclusions: Exclude specific routes or artisan commands
- 🌍 Environment-Specific: Enable only in desired environments
- 📊 Detailed Logging: Optional query SQL and bindings in logs
Installation
Install the package via Composer:
Laravel Auto-Discovery
The package will automatically register its service provider in Laravel 5.5+.
Manual Registration (Laravel 5.4 and below)
Add the service provider to config/app.php:
Configuration
Publish the configuration file:
This will create config/query-watcher.php with the following options:
Main Configuration Options
QUERY_WATCHER_SLOW_QUERY_ENABLED=false
Slow query threshold (milliseconds)
QUERY_WATCHER_SLOW_QUERY_THRESHOLD=1000
Log query details (SQL and bindings)
QUERY_WATCHER_LOG_DETAILS=false
Custom log channel
QUERY_WATCHER_LOG_CHANNEL=stack
[2024-01-15 10:30:45] local.WARNING: [QueryWatcher] High number of DB queries detected on api/users: 75 queries (threshold: 50)
{
"path": "api/users",
"query_count": 75,
"threshold": 50,
"slow_queries_count": 3
}
[2024-01-15 10:30:45] local.WARNING: [QueryWatcher] Slow query detected on api/users: 1250.50ms
{
"path": "api/users",
"execution_time_ms": 1250.50
}
env
QUERY_WATCHER_LOG_CHANNEL=query-watcher
### Excluding Specific Paths
In `config/query-watcher.php`:
### Excluding Artisan Commands
In `config/query-watcher.php`:
## Best Practices
1. **Sensitive Data**: Be cautious when enabling `log_query_details` as it may expose sensitive data in logs
2. **Production**: Consider disabling in production by setting `QUERY_WATCHER_ENABLED=false` or using a separate log channel
3. **Thresholds**: Adjust thresholds based on your application's normal query patterns
4. **Exclusions**: Exclude admin panels, debug tools, and high-traffic endpoints that you're aware of
## Requirements
- PHP 7.2 or higher
- Laravel 5.8, 6.x, 7.x, 8.x, 9.x, 10.x, or 11.x
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Credits
- [HaiHV](https://github.com/ethantechnology)
## Support
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.All versions of laravel-query-watcher with dependencies
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/database Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0