Skip to content

Commit b38a617

Browse files
udpate readme and package class
1 parent 8fa66c4 commit b38a617

File tree

2 files changed

+67
-14
lines changed

2 files changed

+67
-14
lines changed

readme.md

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Laravel-Exception-Notifier | A Laravel Excpetions Email Notification [Package](https://packagist.org/packages/jeremykenedy/laravel-exception-notifier) | v0.0.2
1+
# Laravel-Exception-Notifier | A Laravel Excpetions Email Notification [Package](https://packagist.org/packages/jeremykenedy/laravel-exception-notifier) | v1.0.0
22

33
[![Total Downloads](https://poser.pugx.org/jeremykenedy/laravel-exception-notifier/d/total.svg)](https://packagist.org/packages/jeremykenedy/laravel-exception-notifier)
44
[![Latest Stable Version](https://poser.pugx.org/jeremykenedy/laravel-exception-notifier/v/stable.svg)](https://packagist.org/packages/jeremykenedy/laravel-exception-notifier)
@@ -26,17 +26,74 @@ Laravel exception notifier will send an email of of the error along with the sta
2626
jeremykenedy\laravelexceptionnotifier\LaravelExceptionNotifier::class,
2727
```
2828
29-
3. Publish the packages language files by running the following from your projects root folder:
29+
3. Publish the packages view, mailer, and config files by running the following from your projects root folder:
3030
3131
```
3232
php artisan vendor:publish --tag=laravelexceptionnotifier
3333
```
3434
35-
5. Configure your email settings in the `.env` file.
35+
4. In `App\Exceptions/Handler.php replace the `report()` method with:
3636
37-
5. Add the following (optional) settings to your `.env` file and enter your settings:
37+
```
38+
/**
39+
* Report or log an exception.
40+
*
41+
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
42+
*
43+
* @param \Exception $exception
44+
* @return void
45+
*/
46+
public function report(Exception $exception)
47+
{
48+
49+
$enableEmailExceptions = config('exceptions.emailExceptionEnabled');
50+
51+
if ($enableEmailExceptions === "") {
52+
$enableEmailExceptions = config('exceptions.emailExceptionEnabledDefault');
53+
}
54+
55+
if ($enableEmailExceptions) {
56+
if ($this->shouldReport($exception)) {
57+
$this->sendEmail($exception);
58+
}
59+
}
60+
61+
parent::report($exception);
62+
}
63+
```
64+
65+
5. In `App\Exceptions/Handler.php the method `sendEmail()`:
66+
67+
```
68+
/**
69+
* Sends an email upon exception.
70+
*
71+
* @param \Exception $exception
72+
* @return void
73+
*/
74+
public function sendEmail(Exception $exception)
75+
{
76+
try {
77+
78+
$e = FlattenException::create($exception);
79+
$handler = new SymfonyExceptionHandler();
80+
$html = $handler->getHtml($e);
81+
82+
Mail::send(new ExceptionOccured($html));
83+
84+
} catch (Exception $exception) {
3885
39-
* Note: the defaults for these are located in `config/exception.php`
86+
dd($exception);
87+
88+
}
89+
}
90+
```
91+
92+
6. Configure your email settings in the `.env` file.
93+
94+
7. Add the following (optional) settings to your `.env` file and enter your settings:
95+
96+
* **Note:** the defaults for these are located in `config/exception.php`
4097
4198
```
4299
EMAIL_EXCEPTION_ENABLED=false
@@ -47,6 +104,10 @@ Laravel exception notifier will send an email of of the error along with the sta
47104
EMAIL_EXCEPTION_SUBJECT=''
48105
```
49106
107+
## Screenshots
108+
109+
![Email Notification](https://s3-us-west-2.amazonaws.com/github-project-images/laravel-exception-notifier/exception-error-email-min.jpeg)
110+
50111
## License
51112
52113
Laravel-Exception-Notifier | A Laravel Excpetions Email Notification Package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

src/LaravelExceptionNotifier.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ class LaravelExceptionNotifier extends ServiceProvider
1414
public function boot()
1515
{
1616

17-
// Publish Trait
18-
$this->publishes([
19-
__DIR__.'/App/Traits/ExceptionNotificationHandlerTrait.php' => app_path('Traits/ExceptionNotificationHandlerTrait.php'),
20-
], 'laravelexceptionnotifier');
21-
2217
// Publish Mailer
2318
$this->publishes([
2419
__DIR__.'/App/Mail/ExceptionOccured.php' => app_path('Mail/ExceptionOccured.php'),
@@ -43,9 +38,6 @@ public function boot()
4338
*/
4439
public function register()
4540
{
46-
// Update App with Trait
47-
$this->app->bind(
48-
'App\Traits\ExceptionNotificationHandlerTrait'
49-
);
41+
5042
}
5143
}

0 commit comments

Comments
 (0)