encodia / laravel-something-wrong
A simple package for Laravel to notify handled errors, exceptions and more
Installs: 1 023
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: ^8.2
- bugsnag/bugsnag-laravel: ^2.26
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- larastan/larastan: ^2.9
- nunomaduro/collision: ^7.0|^8.0
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-laravel: ^2.4
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.2
- phpstan/phpstan-phpunit: ^1.4
- phpunit/phpunit: ^9.0|^10.5
This package is auto-updated.
Last update: 2024-11-08 07:44:41 UTC
README
A simple package for Laravel to notify handled errors, exceptions and more.
Note: this package is still under development and currently its features are very limited.
Installation
You can install the package via composer:
composer require encodia/laravel-something-wrong
You can publish the config file with:
php artisan vendor:publish --tag="laravel-something-wrong-config"
Usage
Note: the current version only supports Bugsnag.
This means that anything you notify will use Bugsnag under the hood to send a notification.
Where
Typically, you will inject Encodia\SomethingWrong
in your service class constructor:
use \Encodia\SomethingWrong; class MyService { private SomethingWrong $somethingWrong; public function __construct(SomethingWrong $somethingWrong) { $this->somethingWrong = $somethingWrong; } public function doSomething(): void { // ... $this->somethingWrong ->exception( new \Exception("This wasn't supposed to happen, so let's notify it!") ); // ... } }
If you prefer, you can use its facade:
use \Encodia\SomethingWrong\Facades\SomethingWrong; // ... SomethingWrong::exception( new \Exception("This wasn't supposed to happen, so let's notify it!") );
How
You can notify a simple exception, without any further details:
SomethingWrong::exception( new \Exception("Something wrong happened!") );
If you need to add any details, just pass an array as second argument:
SomethingWrong::exception( new \Exception("Something wrong happened!"), [ 'foo' => 'bar', 'path' => 'a/b/c', 'user' => auth()->user, ], );
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.