Laravel 扩展包 - laravel/telescope 代码调试助手

作者: 温新

分类: 【Laravel 扩展包】

阅读: 890

时间: 2022-12-11 11:11:13

hi,我是温新,一名 PHPer

Laravel Telescope 是 Laravel 框架的优雅调试助手。Telescope 可深入了解进入应用程序的请求,异常,日志条目,数据库查询,排队作业,邮件,通知,缓存操作,计划任务,变量转储等。Telescope 是您本地 Laravel 开发环境的绝佳伴侣。

注意:生产环境不用

1、安装

<span style="color: rgb(255, 192, 0);">composer require laravel/telescope</span><br></br>

2、执行迁移文件

<span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px"><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">php</span> <span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">artisan</span> <span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">telescope</span>:<span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">install</span></span><br></br> <br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px"><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">php</span> <span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">artisan</span> <span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">migrate</span></span>

3、只在开发环境中运行

<span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px"><span style="box-sizing: border-box;color: rgb(98, 151, 85) !important">// App\Providers\AppServiceProvider.php</span></span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px"><span style="box-sizing: border-box"></span></span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px"><span style="box-sizing: border-box;color: rgb(198, 120, 221) !important">public</span> <span style="box-sizing: border-box;color: rgb(198, 120, 221) !important">function</span> <span style="box-sizing: border-box;color: rgb(224, 108, 117) !important">register</span>()</span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px">{</span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px">    <span style="box-sizing: border-box;color: rgb(198, 120, 221) !important">if</span> (<span style="box-sizing: border-box;color: rgb(224, 108, 117) !important">$this</span><span style="box-sizing: border-box;color: rgb(86, 182, 194) !important">-></span><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">app</span><span style="box-sizing: border-box;color: rgb(86, 182, 194) !important">-></span><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">environment</span>(<span style="box-sizing: border-box;color: rgb(152, 195, 121) !important">'local'</span>)) {</span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px">        <span style="box-sizing: border-box;color: rgb(224, 108, 117) !important">$this</span><span style="box-sizing: border-box;color: rgb(86, 182, 194) !important">-></span><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">app</span><span style="box-sizing: border-box;color: rgb(86, 182, 194) !important">-></span><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">register</span>(<span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">\Laravel\Telescope\TelescopeServiceProvider</span>::<span style="box-sizing: border-box;color: rgb(198, 120, 221) !important">class</span>);</span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px">        <span style="box-sizing: border-box;color: rgb(224, 108, 117) !important">$this</span><span style="box-sizing: border-box;color: rgb(86, 182, 194) !important">-></span><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">app</span><span style="box-sizing: border-box;color: rgb(86, 182, 194) !important">-></span><span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">register</span>(<span style="box-sizing: border-box;color: rgb(209, 154, 102) !important">TelescopeServiceProvider</span>::<span style="box-sizing: border-box;color: rgb(198, 120, 221) !important">class</span>);</span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px">    }</span><br></br><span style="box-sizing: border-box;color: rgb(171, 178, 191);padding-right: 0.1px">}</span>

4、使用

<span style="color: rgb(255, 192, 0);">URL/telescope/requests</span><br></br>
请登录后再评论