atmos/laravel-db-sentinel
Composer 安装命令:
composer require atmos/laravel-db-sentinel
包简介
Smart database query monitoring and optimization tool for Laravel 7+.
README 文档
README
Laravel DB Sentinel is a smart database query monitoring and optimization tool for Laravel 7+. It helps Laravel applications track, analyze and optimize database behavior with insights on slow or inefficient queries and actionable performance feedback.
⚠️ Beta Version
This package is currently in Beta. Expect frequent updates and potential breaking changes until we reach version 1.0.0. Please report any issues or bugs on the GitHub repository.
✨ Features
- 📊 Quick Dashboard — A clean UI to visualize your database status.
- 🔍 Query Monitoring — Automatically capture and log all database queries executed by your application.
- 🐢 Slow Query Detection — Highlight queries that exceed a configurable execution threshold.
- 📈 Performance Insights — Collect statistics like query counts, total time spent, and slow query summaries.
- 🧪 Developer-Friendly Output — Easy logs or debug output to help you optimize during development.
- 🛡️ Built-in Authorization: — Restrict access to specific users via User IDs.
- ⚙️ Configurable & Lightweight — Enable or disable features via config — no performance impact in production.
📦 Installation
Install Laravel DB Sentinel via Composer:
composer require atmos/laravel-db-sentinel
⚠️ Important: Run Migrations
After installing the package, you must run:
php artisan migrate
Laravel Auto-Discovery
This package supports Laravel's package auto-discovery, so no manual registration is required.
If auto-discovery is disabled, manually register the service provider in config/app.php:
'providers' => [ Atmos\DbSentinel\DbSentinelServiceProvider::class, ],
🔧 Publishing Package Resources
Laravel DB Sentinel allows you to publish its resources so you can customize them inside your application.
📄 Publish Configuration File
Publish the configuration file to config/db-sentinel.php:
php artisan vendor:publish --tag=db-sentinel-config
🎨 Publish View Files
If the package provides Blade views, publish them with:
php artisan vendor:publish --tag=db-sentinel-views
Published views will be located in:
resources/views/vendor/db-sentinel/
You can safely modify these views without affecting the core package.
💡 Tip: You can run
php artisan vendor:publishwithout arguments to interactively choose which resources to publish.
⚙️ Configuration
DB Sentinel is designed to work out of the box, but you can customize its behavior using the following environment variables in your .env file.
🔌 General & Storage
| Variable | Description | Default |
|---|---|---|
DB_SENTINEL_ENABLED |
Toggle the entire monitoring system. | true |
DB_SENTINEL_CONNECTION |
DB connection to store the DB Sentinel logs (e.g., mysql). |
Your application's default database connection |
DB_SENTINEL_LOGS_TABLE |
The name of the table for stored logs. | sentinel_logs |
DB_SENTINEL_PRUNE_DAYS |
Auto-delete logs older than X days. | 30 |
DB_SENTINEL_SCHEDULE_ENABLED |
Auto-schedule pruning command. | true |
⚡ Performance & Scope
| Variable | Description | Default |
|---|---|---|
DB_SENTINEL_QUEUE_NAME |
Queue for background analysis jobs. | default |
DB_SENTINEL_ALLOWED_CONS |
Connections to monitor (comma-separated). | mysql,mariadb,pgsql,sqlsrv |
DB_SENTINEL_IGNORED_CONS |
Connections to skip (comma-separated). | sqlite,testing |
🖥️ Dashboard & Security
| Variable | Description | Default |
|---|---|---|
DB_SENTINEL_DASHBOARD |
Enable or disable the Web UI. | true |
DB_SENTINEL_PATH |
The URL slug to access the dashboard. | db-sentinel |
DB_SENTINEL_USER_IDS |
Authorized User IDs (comma-separated). | (empty) |
📝 Example .env Setup
# Core Settings DB_SENTINEL_ENABLED=true DB_SENTINEL_PRUNE_DAYS=14 DB_SENTINEL_SCHEDULE_ENABLED=true # Storage & Connection DB_SENTINEL_LOGS_TABLE=custom_sentinel_logs DB_SENTINEL_CONNECTION=mysql # Dashboard Access DB_SENTINEL_PATH=admin/db-metrics DB_SENTINEL_USER_IDS=1,25
⚠️ Important Logic & Security Notes
🔄 Connection Precedence
When configuring your monitoring scope, please note the following hierarchy:
DB_SENTINEL_IGNORED_CONSalways takes precedence.- If a connection is listed in both "allowed" and "ignored," it will be ignored.
- Ensure your primary connection is not accidentally added to the ignored list.
🔒 Dashboard Access
Caution
Be cautious when setting DB_SENTINEL_USER_IDS.
This variable controls who can view your database performance metrics and raw SQL queries.
- Ensure you only input the numeric IDs of trusted administrators.
- If left empty while
DB_SENTINEL_DASHBOARDistrue, access will depend solely on yourauthmiddleware, which may be too permissive depending on your app's setup.
🧹 Pruning
Auto-Pruning
By default, DB Sentinel schedules a daily cleanup of old logs.
Configuration
You can control this behavior in your .env:
# How many days to keep logs DB_SENTINEL_PRUNE_DAYS=30 # Enable/Disable the automatic daily background task DB_SENTINEL_SCHEDULE_ENABLED=true
Tip
If you set DB_SENTINEL_SCHEDULE_ENABLED=false, the package will not register the task. You can then manually add php artisan db-sentinel:prune to your own Scheduler at a specific time that suits your server load.
🧹 Manual Pruning
If you want to clear old logs immediately without waiting for the automated scheduler, you can run the built-in Artisan command.
Usage
Run the following command in your terminal:
php artisan db-sentinel:prune
atmos/laravel-db-sentinel 适用场景与选型建议
atmos/laravel-db-sentinel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「performance」 「optimization」 「laravel」 「query-monitor」 「sql-analyzer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 atmos/laravel-db-sentinel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 atmos/laravel-db-sentinel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 atmos/laravel-db-sentinel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
g4 application profiler package
CSS/Javascript Minificator, Compressor and Concatenator for TYPO3 - highly configurable frontend asset optimization for CSS/JS merging, minification and compression with optional body parsing, async/defer loading, inline output, data-ignore exclusions, SRI integrity validation/calculation, external
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
WordPress mu-plugin to remove jQuery Migrate from the list of jQuery dependencies and to allow jQuery to enqueue before </body> instead of in the <head>.
Store your language lines in the database, yaml or other sources
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-01