samfelgar / log-requests
v2.0
2022-06-28 19:36 UTC
Requires
- php: ^7.4 || ^8.0
- illuminate/contracts: ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/http: ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/routing: ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/support: ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
README
本包提供了一个简单的请求记录器,用于与Laravel应用程序一起使用。
安装
您可以通过composer安装此包
composer require samfelgar/log-requests
默认情况下,使用的日志通道是 stack
,但您可以通过发布配置文件来更改此设置
php artisan vendor:publish --provider=Samfelgar\\LogRequests\\Providers\\LogRequestServiceProvider
运行上述命令后,将在配置路径中创建一个名为 log-requests.php
的文件。
用法
此包注册了一个中间件别名,您可以在路由文件中使用
use Illuminate\Support\Facades\Route; Route::middleware(['log-requests'])->group(function () { // Your logged routes goes here. });
您也可以通过编辑 \App\Http\Kernel
类在组内或全局范围内注册中间件
- 在组内
protected $middlewareGroups = [ 'web' => [ // Other middleware \Samfelgar\LogRequests\Http\Middleware\LogRequest::class, ], 'api' => [ 'throttle:api', 'bindings', \Samfelgar\LogRequests\Http\Middleware\LogRequest::class, ], ];
- 全局
protected $middleware = [ // Other middleware \Samfelgar\LogRequests\Http\Middleware\LogRequest::class, ];
有关Laravel中中间件的更多信息,请参阅文档。
贡献
发现错误?打开一个问题!
任何贡献都受到欢迎,只需提交一个拉取请求。