Skip to content

Commit ed2d5fc

Browse files
committed
docs: Update README - especially for Laravel 9 - 10
1 parent 8f0dc81 commit ed2d5fc

File tree

1 file changed

+8
-51
lines changed

1 file changed

+8
-51
lines changed

readme.md

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,7 @@ Register the package with laravel in `config/app.php` under `providers` with the
7777
#### Laravel 9 and Above use:
7878

7979
```php
80-
use App\Mail\ExceptionOccurred;
81-
use Illuminate\Support\Facades\Log;
82-
use Illuminate\Support\Facades\Mail;
83-
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
84-
use Throwable;
80+
use App\Traits\ExceptionNotificationHandlerTrait;
8581
```
8682

8783
#### Laravel 8 and Below use:
@@ -97,24 +93,15 @@ Register the package with laravel in `config/app.php` under `providers` with the
9793
5. Update `App\Exceptions\Handler.php`
9894

9995
#### Laravel 9 and Above:
100-
##### In `App\Exceptions\Handler.php` replace the `register()` method with:
10196

97+
##### Add trait to `Handler` class:
10298
```php
103-
/**
104-
* Register the exception handling callbacks for the application.
105-
*
106-
* @return void
107-
*/
108-
public function register()
109-
{
110-
$this->reportable(function (Throwable $e) {
111-
$this->sendEmail($e);
112-
});
113-
}
99+
use ExceptionNotificationHandlerTrait;
114100
```
115101

116102
#### Laravel 8 and Below:
117-
##### In `App\Exceptions\Handler.php` replace the `report()` method with:
103+
104+
##### Replace the `report()` method with:
118105

119106
```php
120107
/**
@@ -142,37 +129,7 @@ Register the package with laravel in `config/app.php` under `providers` with the
142129
}
143130
```
144131
145-
6. In `App\Exceptions\Handler.php` add the method `sendEmail()`:
146-
147-
#### Laravel 9 and Above:
148-
149-
```php
150-
/**
151-
* Sends an email upon exception.
152-
*
153-
* @param Throwable $exception
154-
*
155-
* @return void
156-
*/
157-
public function sendEmail(Throwable $exception)
158-
{
159-
try {
160-
$content['message'] = $exception->getMessage();
161-
$content['file'] = $exception->getFile();
162-
$content['line'] = $exception->getLine();
163-
$content['trace'] = $exception->getTrace();
164-
$content['url'] = request()->url();
165-
$content['body'] = request()->all();
166-
$content['ip'] = request()->ip();
167-
Mail::send(new ExceptionOccurred($content));
168-
} catch (Throwable $exception) {
169-
Log::error($exception);
170-
}
171-
}
172-
```
173-
174-
#### Laravel 8 and Below:
175-
132+
##### Add the method `sendEmail()`:
176133
```php
177134
/**
178135
* Sends an email upon exception.
@@ -195,9 +152,9 @@ Register the package with laravel in `config/app.php` under `providers` with the
195152
}
196153
```
197154
198-
7. Configure your email settings in the `.env` file.
155+
6. Configure your email settings in the `.env` file.
199156
200-
8. Add the following (optional) settings to your `.env` file and enter your settings:
157+
7. Add the following (optional) settings to your `.env` file and enter your settings:
201158
202159
* **Note:** the defaults for these are located in `config/exception.php`
203160

0 commit comments

Comments
 (0)