kiwilan / sentinel-laravel
PHP package for Laravel to send errors to Sentinel.
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-11-29 20:54:06 UTC
README
PHP package for Laravel to send errors to Sentinel.
Note
Sentinel is an open-source error tracking tool.
Installation
You can install the package via composer:
composer require kiwilan/sentinel-laravel
You can publish the config file with:
php artisan vendor:publish --tag="sentinel-config"
This is the contents of the published config file:
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), ];
Usage
Automatic
Just execute the sentinel:install
Artisan command. It will automatically install the package and configure it for you.
php artisan sentinel:install
Manual
In 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); }); } }
If you want to debug your installation, you can set true
to throwErrors
: \Kiwilan\Sentinel\Facades\Sentinel::register($e, throwErrors: true)
.
Warning
Do not use throwErrors
in production, if Sentinel instance is not available, your application will crash.
Verify your installation
Use the sentinel:test
Artisan command to verify your installation.
php artisan sentinel:test
You can verify your installation by throwing an exception from a route or controller.
For example, in routes/web.php
:
Route::get('/debug-sentinel', function () { throw new \Exception('Sentinel error!'); });
Testing
cp .env.example .env
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Ewilan Rivière
spatie
forspatie/laravel-package-tools
- All Contributors
License
The MIT License (MIT). Please see License File for more information.