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.
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"
Note: the current version only supports Bugsnag.
This means that anything you notify will use Bugsnag under the hood to send a notification.
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!")
);
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,
],
);
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.