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 )
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 )
@@ -21,15 +21,23 @@ Laravel exception notifier will send an email of the error along with the stack
2121Get the errors and fix them before the client even reports them, that's why this exists!
2222
2323## 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 )
2525
2626## Installation Instructions
27271 . From your projects root folder in terminal run:
2828
29+ Laravel 7+ use:
30+
2931 ```
3032 composer require jeremykenedy/laravel-exception-notifier
3133 ```
3234
35+ Laravel 6 and below use:
36+
37+ ```
38+ composer require jeremykenedy/laravel-exception-notifier:1.2.0
39+ ```
40+
33412. Register the package
3442* Laravel 5.5 and up
3543Uses 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
4755 php artisan vendor:publish --tag=laravelexceptionnotifier
4856 ```
4957
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:
5159
5260```
5361 use App\Mail\ExceptionOccured;
5462 use Illuminate\Support\Facades\Log;
5563 use Mail;
56- use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
5764 use Symfony\Component\Debug\Exception\FlattenException;
65+ use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
5866```
5967
60685. In `App\Exceptions\Handler.php` replace the `report()` method with:
6169
6270 ```
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');
8586 }
86- ```
8787
88- 6. In `App\Exceptions\Handler.php` add the method `sendEmail()`:
88+ if ($enableEmailExceptions && $this->shouldReport($exception)) {
89+ $this->sendEmail($exception);
90+ }
8991
92+ parent::report($exception);
93+ }
9094 ```
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));
10695
107- } catch (Exception $exception) {
108-
109- Log::error($exception);
96+ 6. In `App\Exceptions\Handler.php` add the method `sendEmail()`:
11097
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);
112116 }
117+ }
113118 ```
114119
1151207. Configure your email settings in the `.env` file.
0 commit comments