alicfeng/laravel-runtime is a Laravel package for laravel runtime library.
It currently has 9 GitHub stars and 735 downloads on Packagist (latest version v1.0).
Install it with composer require alicfeng/laravel-runtime.
Discover more Laravel packages by alicfeng
or browse all Laravel packages to compare alternatives.
Last updated
laravel-runtime features for Laravel Application
laravel-runtime此项目为Laravel中的插件
无论在开发、测试还是生产环境中,我们皆比较注重请求的数据,一般的做法是将有价值的数据写入在日志当中,便于调试、问题排查等,在Request到达控制器前处理数据信息的写入,在此使用Http中间件拦截处理,即在请求在中间件中做日志记载。
同时、在开发以及测试的时候,一个合格的开发者总是会关注其接口是否存在性能上的问题,比如接口请求的时间消耗多少等,此插件可以通过CLI模式在终端以表格的形式展示接口的基本状况,web端界面亦可以简约展示,如下图所示
CLI终端
WEB端
PHP>=7.0composerlaravelcomposer require "alicfeng/laravel-runtime"
在config/app.php配置中添加
AlicFeng\Runtime\ServiceProvider\RuntimeServiceProvider::class
在app/Http/Kernel.php中添加中间件
\AlicFeng\Runtime\Middleware\RuntimeMiddleware::class
生成配置文件
php artisan vendor:publish --provider="AlicFeng\Runtime\ServiceProvider\RuntimeServiceProvider"
CLI#使用帮助
➜ php artisan samego:runtime help
usage:
php artisan samego:runtime [help] [--service {reload|analysis}] [--start] [--end]
# 查看接口请求情况分析(支持时间段)
➜ php artisan samego:runtime --service=analysis
➜ php artisan samego:runtime --service=analysis --start={opition|strtotime|0}
➜ php artisan samego:runtime --service=analysis --end={opition|strtotime|time()}
# 分析数据重载
➜ php artisan samego:runtime --service=reload
WEB浏览器打开$host/runtime/analysis即可看到展示~
➜ tail -f storage/logs/laravel-2019-04-24.log
[2019-04-24 11:38:44] production.INFO: trace request message begin
[2019-04-24 11:38:44] production.INFO: router : order/v1/interface/name
[2019-04-24 11:38:44] production.INFO: method : POST
[2019-04-24 11:38:44] production.INFO: ip : 113.118.235.220
[2019-04-24 11:38:44] production.INFO: params : {"header":{"userToken":"token"},"body":{"param":"alicfeng"}
[2019-04-24 11:38:44] production.INFO: trace request message end