PHP code example of zanysoft / laravel-exception-monitor
1. Go to this page and download the library: Download zanysoft/laravel-exception-monitor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zanysoft / laravel-exception-monitor example snippets
return [
/*
|--------------------------------------------------------------------------
| Enabled sender drivers
|--------------------------------------------------------------------------
|
| Send a notification about exception in your application to supported channels.
|
| Supported: "mail", "slack". You can use multiple drivers.
|
*/
'drivers' => [ 'mail', 'slack' ],
/*
|--------------------------------------------------------------------------
| Enabled application environments
|--------------------------------------------------------------------------
|
| Set environments that should generate notifications.
|
*/
'environments' => [ 'production'],
/*
|--------------------------------------------------------------------------
| Disable Error Notifications
|--------------------------------------------------------------------------
|
| Set status code for disable notifications. like [401,404,500]
|
*/
'skip_error' => [401, 404, 405, 500],
/*
|--------------------------------------------------------------------------
| Mail Configuration
|--------------------------------------------------------------------------
|
| It uses your app default Mail driver. You shouldn't probably touch the view
| property unless you know what you're doing.
|
*/
'mail' => [
'from' => '[email protected]',
'to' => '[email protected]',
'view' => 'mails/exception-monitor'
],
/*
* set endpoint url from Incoming WebHooks https://my.slack.com/services/new/incoming-webhook
*/
'slack' => [
'endpoint' => 'https://hooks.slack.com/services/....',
'channel' => '#bugtracker',
'username' => 'Exception Monitor',
'icon' => ':robot_face:',
],
];
use ZanySoft\LaravelExceptionMonitor\MonitorExceptionHandler;
...
class Handler extends MonitorExceptionHandler
public function report(Exception $e)
{
foreach ($this->dontReport as $type) {
if ($e instanceof $type) {
return parent::report($e);
}
}
if (app()->bound('exception-monitor')) {
app('exception-monitor')->notifyException($e);
}
// OR
ExceptionMonitor::notifyException($e);
parent::report($e);
}