一、 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"
在配置文件中 dsn 就在我们看的文档下方,每个用户的 dsn 都是唯一的,在你的项目中配置了 dsn ,Sentry 就能监控你的项目。
好了基本配置就这么完事儿,然后现在我们访问当前项目,然后在路由上面乱输入一通。
我们会及时收到错误反馈
当然也会往我们的邮箱里面发送