1
- # Laravel Exception Notifier | A Laravel Exceptions Email Notification [ Package] ( https://packagist.org/packages/jeremykenedy/laravel-exception-notifier )
1
+ # Laravel Exception Notifier | A Laravel 5, 6, and 7 Exceptions Email Notification [ Package] ( https://packagist.org/packages/jeremykenedy/laravel-exception-notifier )
2
2
3
3
[ ![ Total Downloads] ( https://poser.pugx.org/jeremykenedy/laravel-exception-notifier/d/total.svg )] ( https://packagist.org/packages/jeremykenedy/laravel-exception-notifier )
4
4
[ ![ Latest Stable Version] ( https://poser.pugx.org/jeremykenedy/laravel-exception-notifier/v/stable.svg )] ( https://packagist.org/packages/jeremykenedy/laravel-exception-notifier )
@@ -21,15 +21,23 @@ Laravel exception notifier will send an email of the error along with the stack
21
21
Get the errors and fix them before the client even reports them, that's why this exists!
22
22
23
23
## Requirements
24
- * [ Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8+] ( https://laravel.com/docs/installation )
24
+ * [ Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, & 7 +] ( https://laravel.com/docs/installation )
25
25
26
26
## Installation Instructions
27
27
1 . From your projects root folder in terminal run:
28
28
29
+ Laravel 7+ use:
30
+
29
31
```
30
32
composer require jeremykenedy/laravel-exception-notifier
31
33
```
32
34
35
+ Laravel 6 and below use:
36
+
37
+ ```
38
+ composer require jeremykenedy/laravel-exception-notifier:1.2.0
39
+ ```
40
+
33
41
2. Register the package
34
42
* Laravel 5.5 and up
35
43
Uses package auto discovery feature, no need to edit the `config/app.php` file.
@@ -47,69 +55,66 @@ Register the package with laravel in `config/app.php` under `providers` with the
47
55
php artisan vendor:publish --tag=laravelexceptionnotifier
48
56
```
49
57
50
- 4. In `App\Exceptions\Handler.php` include the following classes in the head:
58
+ 4. In `App\Exceptions\Handler.php` include the additional following classes in the head:
51
59
52
60
```
53
61
use App\Mail\ExceptionOccured;
54
62
use Illuminate\Support\Facades\Log;
55
63
use Mail;
56
- use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
57
64
use Symfony\Component\Debug\Exception\FlattenException;
65
+ use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
58
66
```
59
67
60
68
5. In `App\Exceptions\Handler.php` replace the `report()` method with:
61
69
62
70
```
63
- /**
64
- * Report or log an exception.
65
- *
66
- * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
67
- *
68
- * @param \Exception $exception
69
- * @return void
70
- */
71
- public function report(Exception $exception)
72
- {
73
-
74
- $enableEmailExceptions = config('exceptions.emailExceptionEnabled');
75
-
76
- if ($enableEmailExceptions === "") {
77
- $enableEmailExceptions = config('exceptions.emailExceptionEnabledDefault');
78
- }
79
-
80
- if ($enableEmailExceptions && $this->shouldReport($exception)) {
81
- $this->sendEmail($exception);
82
- }
83
-
84
- parent::report($exception);
71
+ /**
72
+ * Report or log an exception.
73
+ *
74
+ * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
75
+ *
76
+ * @param \Throwable $exception
77
+ *
78
+ * @return void
79
+ */
80
+ public function report(Throwable $exception)
81
+ {
82
+ $enableEmailExceptions = config('exceptions.emailExceptionEnabled');
83
+
84
+ if ($enableEmailExceptions === '') {
85
+ $enableEmailExceptions = config('exceptions.emailExceptionEnabledDefault');
85
86
}
86
- ```
87
87
88
- 6. In `App\Exceptions\Handler.php` add the method `sendEmail()`:
88
+ if ($enableEmailExceptions && $this->shouldReport($exception)) {
89
+ $this->sendEmail($exception);
90
+ }
89
91
92
+ parent::report($exception);
93
+ }
90
94
```
91
- /**
92
- * Sends an email upon exception.
93
- *
94
- * @param \Exception $exception
95
- * @return void
96
- */
97
- public function sendEmail(Exception $exception)
98
- {
99
- try {
100
-
101
- $e = FlattenException::create($exception);
102
- $handler = new SymfonyExceptionHandler();
103
- $html = $handler->getHtml($e);
104
-
105
- Mail::send(new ExceptionOccured($html));
106
95
107
- } catch (Exception $exception) {
108
-
109
- Log::error($exception);
96
+ 6. In `App\Exceptions\Handler.php` add the method `sendEmail()`:
110
97
111
- }
98
+ ```
99
+ /**
100
+ * Sends an email upon exception.
101
+ *
102
+ * @param \Throwable $exception
103
+ *
104
+ * @return void
105
+ */
106
+ public function sendEmail(Throwable $exception)
107
+ {
108
+ try {
109
+ $e = FlattenException::create($exception);
110
+ $handler = new SymfonyExceptionHandler();
111
+ $html = $handler->getHtml($e);
112
+
113
+ Mail::send(new ExceptionOccured($html));
114
+ } catch (Throwable $exception) {
115
+ Log::error($exception);
112
116
}
117
+ }
113
118
```
114
119
115
120
7. Configure your email settings in the `.env` file.
0 commit comments