imransaleem/http-db-logger
最新稳定版本:v1.0.1
Composer 安装命令:
composer require imransaleem/http-db-logger
包简介
Middleware to log HTTP requests and responses to database
README 文档
README
A Laravel middleware package to log all incoming HTTP requests into the database.
📦 Installation
You can install the package via Composer:
composer require imransaleem/http-db-logger
🔧 Configuration (Optional)
If you're not using Laravel package auto-discovery, add the service provider manually in config/app.php:
'providers' => [ // Other service providers... Imransaleem\HttpDbLogger\HttpDbLoggerServiceProvider::class, ],
🛡 Register Middleware
Add the middleware in app/Http/Kernel.php:
protected $middleware = [ // Other middleware... \Imransaleem\HttpDbLogger\Middleware\LogHttpToDatabase::class, ];
🚀 Publish Configuration & Migration
To publish the config and migration files, run:
php artisan vendor:publish --tag=config php artisan vendor:publish --tag=migrations
Then run the migration:
php artisan migrate
✅ Example Usage
You can apply the middleware to a specific route group like this:
use \Imransaleem\HttpDbLogger\Middleware\LogHttpToDatabase; Route::middleware(['auth', LogHttpToDatabase::class])->group(function () { Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); });
⚙️ Configuration Options
You can customize the logger via config/http-db-logger.php. Options include:
log_requests: boolean default true,log_authenticated_user: Log user ID and role if authenticated.table: logging table for database
🗃 Database Table
The package creates a http_db_logs table with the following fields:
idmethoduriipheadersbodycreated_by(nullable)user_role(nullable)created_at/updated_at
© 2025 Imran Saleem — Licensed under MIT
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-30