kiwilan / sentinel-laravel
PHP包,用于Laravel将错误发送到Sentinel。
0.0.33
2023-10-11 15:03 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
- vlucas/phpdotenv: ^5.5
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-08-29 20:17:06 UTC
README
PHP包,用于Laravel将错误发送到Sentinel。
注意
Sentinel是一个开源的错误跟踪工具。
安装
您可以通过Composer安装此包
composer require kiwilan/sentinel-laravel
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="sentinel-config"
这是发布配置文件的内容
return [ /** * If you want to disable Sentinel, set `SENTINEL_ENABLED` to `false`. */ 'enabled' => env('SENTINEL_ENABLED', true), /** * Sentinel host where your application is registered. */ 'host' => env('SENTINEL_HOST', 'http://app.sentinel.test'), /** * Token is used to authenticate your application with Sentinel. */ 'token' => env('SENTINEL_TOKEN'), /** * If you want to throw Sentinel errors for debug, set `SENTINEL_DEBUG` to `true`. * WARNING: do not use it on production. */ 'debug' => env('SENTINEL_DEBUG', false), ];
使用方法
自动
只需执行sentinel:install
Artisan命令。它将自动安装包并为您配置。
php artisan sentinel:install
手动
在app/Exceptions/Handler.php
<?php namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; class Handler extends ExceptionHandler { /** * Register the exception handling callbacks for the application. */ public function register(): void { $this->reportable(function (Throwable $e) { \Kiwilan\Sentinel\Facades\Sentinel::register($e); }); } }
如果您想调试安装,可以将throwErrors
设置为true
:\Kiwilan\Sentinel\Facades\Sentinel::register($e, throwErrors: true)
。
警告
在生产环境中不要使用throwErrors
,如果Sentinel实例不可用,您的应用程序可能会崩溃。
验证您的安装
使用sentinel:test
Artisan命令来验证您的安装。
php artisan sentinel:test
您可以通过从一个路由或控制器抛出异常来验证您的安装。
例如,在routes/web.php
Route::get('/debug-sentinel', function () { throw new \Exception('Sentinel error!'); });
测试
cp .env.example .env
composer test
更新日志
有关最近更改的更多信息,请参阅更新日志。
贡献
有关详细信息,请参阅贡献指南。
鸣谢
- Ewilan Rivière
spatie
为spatie/laravel-package-tools
- 所有贡献者
许可
MIT许可(MIT)。有关更多信息,请参阅许可文件。