rsands2801/sentry-laravel
Composer 安装命令:
composer require rsands2801/sentry-laravel
包简介
Laravel integration for Sentry (https://sentry.io)
README 文档
README
Laravel integration for Sentry.
Laravel 5.x
Install the sentry/sentry-laravel package:
$ composer require sentry/sentry-laravel
Add the Sentry service provider and facade in config/app.php:
'providers' => array( // ... Sentry\SentryLaravel\SentryLaravelServiceProvider::class, ) 'aliases' => array( // ... 'Sentry' => Sentry\SentryLaravel\SentryFacade::class, )
Add Sentry reporting to app/Exceptions/Handler.php:
public function report(Exception $exception) { if ($this->shouldReport($exception)) { app('sentry')->captureException($exception); } parent::report($exception); }
Create the Sentry configuration file (config/sentry.php):
$ php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"
Add your DSN to .env:
SENTRY_DSN=https://public:secret@sentry.example.com/1
Laravel 4.x
Install the sentry/sentry-laravel package:
$ composer require sentry/sentry-laravel
Add the Sentry service provider and facade in config/app.php:
'providers' => array( // ... 'Sentry\SentryLaravel\SentryLaravelServiceProvider', ) 'aliases' => array( // ... 'Sentry' => 'Sentry\SentryLaravel\SentryFacade', )
Create the Sentry configuration file (config/sentry.php):
$ php artisan config:publish sentry/sentry-laravel
Lumen 5.x
Install the sentry/sentry-laravel package:
$ composer require sentry/sentry-laravel
Register Sentry in bootstrap/app.php:
$app->register('Sentry\SentryLaravel\SentryLumenServiceProvider'); # Sentry must be registered before routes are included require __DIR__ . '/../app/Http/routes.php';
Add Sentry reporting to app/Exceptions/Handler.php:
public function report(Exception $e) { if ($this->shouldReport($e)) { app('sentry')->captureException($e); } parent::report($e); }
Create the Sentry configuration file (config/sentry.php):
<?php return array( 'dsn' => '___DSN___', // capture release as git sha // 'release' => trim(exec('git log --pretty="%h" -n1 HEAD')), // Capture bindings on SQL queries 'breadcrumbs.sql_bindings' => true, // Capture default user context 'user_context' => true, );
Adding Context
The mechanism to add context will vary depending on which version of Laravel you're using, but the general approach is the same. Find a good entry point to your application in which the context you want to add is available, ideally early in the process.
In the following example, we'll use a middleware:
namespace App\Http\Middleware; use Closure; class SentryContext { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (app()->bound('sentry')) { /** @var \Raven_Client $sentry */ $sentry = app('sentry'); // Add user context if (auth()->check()) { $sentry->user_context([...]); } else { $sentry->user_context(['id' => null]); } // Add tags context $sentry->tags_context([...]); } return $next($request); } }
Contributing
First, make sure you can run the test suite. Install development dependencies :
$ composer install
You may now use phpunit :
$ vendor/bin/phpunit
Resources
- Bug Tracker
- Code
- Mailing List
- IRC (irc.freenode.net, #sentry)
rsands2801/sentry-laravel 适用场景与选型建议
rsands2801/sentry-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「errors」 「laravel」 「sentry」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rsands2801/sentry-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rsands2801/sentry-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rsands2801/sentry-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Zend Framework module that sets up Monolog for logging in applications.
Bootstraps errors and handles them via reporters and renderers
Asynchronous Sentry for Symfony - Fire and forget
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
Monitors errors and exceptions and reports them to Rollbar
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2016-11-18