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 )
@@ -16,100 +16,105 @@ Table of contents:
1616- [ License] ( #license )
1717
1818## About
19- Laravel exception notifier will send an email of the error along with the stack trace to the chosen recipients. [ This Package] ( https://packagist.org/packages/jeremykenedy/laravel-exception-notifier ) includes all necessary traits, views, configs, and Mailers for email notifications upon your applications exceptions. You can customize who send to, cc to, bcc to, enable/disable, and custom subject or default subject based on environment. Built for Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, and 5.8+.
19+ Laravel exception notifier will send an email of the error along with the stack trace to the chosen recipients. [ This Package] ( https://packagist.org/packages/jeremykenedy/laravel-exception-notifier ) includes all necessary traits, views, configs, and Mailers for email notifications upon your applications exceptions. You can customize who send to, cc to, bcc to, enable/disable, and custom subject or default subject based on environment. Built for Laravel 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7 +.
2020
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+, 6, or 7 +] ( https://laravel.com/docs/installation )
2525
2626## Installation Instructions
27271 . From your projects root folder in terminal run:
2828
29- ```
29+ Laravel 7+ use:
30+
31+ ``` bash
3032 composer require jeremykenedy/laravel-exception-notifier
3133 ```
3234
35+ Laravel 6 and below use:
36+
37+ ` ` ` bash
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.
3644
3745* Laravel 5.4 and below
3846Register the package with laravel in ` config/app.php` under ` providers` with the following:
3947
40- ```
48+ ` ` ` php
4149 jeremykenedy\l aravelexceptionnotifier\L aravelExceptionNotifier::class,
4250 ` ` `
4351
44523. Publish the packages view, mailer, and config files by running the following from your projects root folder:
4553
46- ```
54+ ` ` ` bash
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\E xceptions\H andler.php` include the additional following classes in the head:
5159
52- ```
60+ ` ` ` php
5361 use App\M ail\E xceptionOccured;
5462 use Illuminate\S upport\F acades\L og;
5563 use Mail;
56- use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
5764 use Symfony\C omponent\D ebug\E xception\F lattenException;
65+ use Symfony\C omponent\D ebug\E xceptionHandler as SymfonyExceptionHandler;
5866` ` `
5967
60685. In ` App\E xceptions\H andler.php` replace the `report ()` method with:
6169
62- ```
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);
70+ ` ` ` php
71+ /**
72+ * Report or log an exception.
73+ *
74+ * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
75+ *
76+ * @param \T hrowable $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);
10495
105- Mail::send(new ExceptionOccured($html));
106-
107- } catch (Exception $exception) {
108-
109- Log::error($exception);
96+ 6. In ` App\E xceptions\H andler.php` add the method ` sendEmail()` :
11097
111- }
98+ ` ` ` php
99+ /**
100+ * Sends an email upon exception.
101+ *
102+ * @param \T hrowable $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.
@@ -118,9 +123,9 @@ Register the package with laravel in `config/app.php` under `providers` with the
118123
119124 * ** Note:** the defaults for these are located in ` config/exception.php`
120125
121- ```
126+ ` ` ` bash
122127 EMAIL_EXCEPTION_ENABLED=false
123- EMAIL_EXCEPTION_FROM='email@email.com'
128+ EMAIL_EXCEPTION_FROM=" ${MAIL_FROM_ADDRESS} "
124129 EMAIL_EXCEPTION_TO=' email1@gmail.com, email2@gmail.com'
125130 EMAIL_EXCEPTION_CC=' '
126131 EMAIL_EXCEPTION_BCC=' '
0 commit comments