一、 PHP Laravel 框架安装sentry模块

$ composer require sentry/sentry-laravel

添加进服务提供者和门面

'providers' => array(
    // ...
    Sentry\SentryLaravel\SentryLaravelServiceProvider::class,
)

'aliases' => array(
    // ...
    'Sentry' => Sentry\SentryLaravel\SentryFacade::class,
)

然后在 App/Exceptions/Handler.php report 修改如下方法

public function report(Exception $exception)
{
    if ($this->shouldReport($exception)) {
        app('sentry')->captureException($exception);
    }
    parent::report($exception);
}

生成配置文件, 配置文件在 config/sentry.php

$ php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"

GfGjCHYfcl.png

在配置文件中 dsn 就在我们看的文档下方,每个用户的 dsn 都是唯一的,在你的项目中配置了 dsn ,Sentry 就能监控你的项目。

2.png

好了基本配置就这么完事儿,然后现在我们访问当前项目,然后在路由上面乱输入一通。

3.png

我们会及时收到错误反馈

4.png

当然也会往我们的邮箱里面发送

5.png

最后修改:2018 年 09 月 09 日 07 : 34 PM
如果觉得我的文章对你有用,请随意赞赏