Skip to content

Commit c360c59

Browse files
tortuetorcherobbielovetylercd100
authored
PHP 8.0 support 🚀 and more (#78)
* update composer for Laravel 6.0.4 * update composer for Laravel ^6.0, raise minimum php version to 7.1 * update input facade to request * fix Components/Notifier.php * update composer.json for Laravel 7 * update composer.json for Laravel 7 * update Exception classes to Throwables * more fixes but one part unsure (ddd()) * more fixes * revert change in NotifierFailedException.php * Support Laravel 6, 7 and 8 With PHP >= 7.2 * Clean Travis Ci config * Use 'next' branch for laravel-notify * Update README.md To use Throwable instead of Exception for the report() method signature * Fix PHP 7.4 error with PHPUnit See: sebastianbergmann/phpunit#3728 * PHP 8.0 support * Add Sentry driver to replace Raven Because RavenHandler was removed from Monolog since version 2.0 * Update CHANGELOG and README * Clean Composer file Use the upcoming 'tylercd100/laravel-notify' 4.0.0 version * Remove prefer lowest from travis Co-authored-by: Robbie Love <[email protected]> Co-authored-by: Tyler Arbon <[email protected]>
1 parent 26df3cd commit c360c59

13 files changed

+111
-113
lines changed

.travis.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
language: php
22

33
php:
4-
- 7.2
4+
- 7.2
5+
- 7.3
6+
- 7.4
7+
- 8.0snapshot
58

69
env:
7-
matrix:
8-
# - COMPOSER_FLAGS="--prefer-lowest"
9-
- COMPOSER_FLAGS=""
10+
matrix:
11+
- COMPOSER_FLAGS=""
1012

1113
before_script:
12-
- travis_retry composer self-update
13-
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction
14+
- travis_retry composer self-update
15+
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
1416

1517
# script:
1618
# - vendor/bin/phpunit --coverage-clover build/logs/clover.xml

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to `LERN` will be documented in this file.
44

5+
### Unreleased
6+
- Updated for Laravel 7 and 8
7+
- Add support for PHP 7.3, 7.4, 8.0
8+
- Removed support for Laravel 5.5, 5.6, 5.7, 5.8
9+
- Removed support for PHP 7.0, 7.1
10+
- Removed deprecated RavenHandler handler, use sentry/sentry 3.x and their Sentry\Monolog\Handler instead
11+
- Removed deprecated HipChat handler, migrate to Slack and use SlackWebhookHandler or SlackHandler instead
12+
513
### 5.0.0
614
- Updated for Laravel 6
715

README.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ Currently supported notification channels via [Monolog](https://github.com/Selda
1414
- Email
1515
- [Pushover](https://pushover.net/)
1616
- [Slack](https://slack.com/)
17-
- [Hipchat](https://www.hipchat.com/)
1817
- [Fleephook](https://fleep.io/)
1918
- [Flowdock](https://www.flowdock.com/)
2019
- [Plivo](https://www.plivo.com/) an SMS messaging service.
2120
- [Twilio](https://www.twilio.com/) an SMS messaging service.
22-
- [Sentry](https://getsentry.com) via [Raven](https://github.com/getsentry/raven-php)
21+
- [Sentry](https://getsentry.com) via [Sentry SDK for PHP](https://github.com/getsentry/sentry-php)
2322
- [Mailgun](https://mailgun.com)
2423

2524
## Version Compatibility
@@ -32,15 +31,17 @@ Currently supported notification channels via [Monolog](https://github.com/Selda
3231
5.4.x | 3.x
3332
5.5.x | 4.x
3433
5.6.x | 4.x
35-
6.x | 5.x
34+
6.x | 5.x and 6.x
35+
7.x | 6.x
36+
8.x | 6.x
3637

3738
## Migrating from `3.x` to `4.x`
3839
Make sure that the config file now includes the new `lern.notify.class` and `lern.record.class` settings. Check the [config file](https://github.com/tylercd100/lern/blob/master/config/lern.php) to see how they are used.
3940

4041
## Migrating from `2.x` to `3.x`
4142
Version 3.x introduces the ability to collect more information from the error such as the user_id, url, method, and input data. In order to use 3.x you will need to copy over the new [config file](https://github.com/tylercd100/lern/blob/master/config/lern.php), the migration file and then migrate it.
4243
```php
43-
# This will only copy over the migration file. For the config file you can either include the --force flag (Which will overwrite it) or copy it manually from github
44+
# This will only copy over the migration file. For the config file you can either include the --force flag (Which will overwrite it) or copy it manually from github
4445
php artisan vendor:publish --provider="Tylercd100\LERN\LERNServiceProvider"
4546
php artisan migrate
4647
```
@@ -59,18 +60,18 @@ Then you will need to run these commands in the terminal in order to copy the co
5960
php artisan vendor:publish --provider="Tylercd100\LERN\LERNServiceProvider"
6061
```
6162

62-
Before you run the migration you may want to take a look at `config/lern.php` and change the `table` property to a table name that you would like to use. After that run the migration
63+
Before you run the migration you may want to take a look at `config/lern.php` and change the `table` property to a table name that you would like to use. After that run the migration
6364
```bash
6465
php artisan migrate
6566
```
6667

6768
## Usage
6869
To use LERN modify the report method in the `app/Exceptions/Handler.php` file
6970
```php
70-
public function report(Exception $e)
71+
public function report(Throwable $e)
7172
{
7273
if ($this->shouldReport($e)) {
73-
74+
7475
//Check to see if LERN is installed otherwise you will not get an exception.
7576
if (app()->bound("lern")) {
7677
app()->make("lern")->handle($e); //Record and Notify the Exception
@@ -82,17 +83,19 @@ public function report(Exception $e)
8283
*/
8384
}
8485
}
85-
86+
8687
return parent::report($e);
8788
}
8889
```
8990

90-
Dont forget to add this to the top of the file
91+
Dont forget to add this to the top of the file
9192
```php
9293
//If you updated your aliases array in "config/app.php"
9394
use LERN;
95+
use Throwable;
9496
//or if you didnt...
9597
use Tylercd100\LERN\Facades\LERN;
98+
use Throwable;
9699
```
97100

98101
### Recording
@@ -143,7 +146,7 @@ LERN uses the Monolog library to send notifications. If you need more than the s
143146
#### Changing the log level programmatically
144147
Some notification services support different log levels. If changing the config value `lern.notify.log_level` is not enough then try it this way:
145148
```php
146-
// Change the log level.
149+
// Change the log level.
147150
// Default is: critical
148151
// Options are: debug, info, notice, warning, error, critical, alert, emergency
149152
LERN::setLogLevel("emergency");
@@ -176,8 +179,8 @@ Make sure that you set the view config value to null or the `LERN::setMessage()`
176179
#### Custom Monolog Handlers
177180
To use a custom Monolog Handler call the `pushHandler` method
178181
```php
179-
use Monolog\Handler\HipChatHandler;
180-
$handler = new HipChatHandler($token,$room);
182+
use Monolog\Handler\SlackHandler;
183+
$handler = new SlackHandler($token, $channel);
181184
LERN::pushHandler($handler);
182185
LERN::notify($exception);
183186
```

composer.json

+11-12
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@
2929
"Tylercd100\\LERN\\Tests\\": "tests/"
3030
}
3131
},
32-
"minimum-stability": "stable",
32+
"minimum-stability": "dev",
33+
"prefer-stable": true,
3334
"require": {
34-
"php": "^7.2",
35-
"illuminate/support": "^6.0",
36-
"monolog/monolog": "^1.22",
37-
"tylercd100/laravel-notify": "^3.0"
35+
"php": "^7.2|^8.0",
36+
"illuminate/support": "^6.0|^7.0|^8.0",
37+
"monolog/monolog": "^2.0",
38+
"tylercd100/laravel-notify": "^4.0"
3839
},
3940
"require-dev": {
40-
"orchestra/testbench": "^4.0",
41-
"phpunit/phpunit": "^8.0",
42-
"doctrine/dbal": "~2.3"
41+
"mockery/mockery": "~1.3.3|^1.4.2",
42+
"orchestra/testbench": "^4.0|^5.0|^6.0",
43+
"phpunit/phpunit": "^8.4|^9.3.3",
44+
"doctrine/dbal": "^2.6|^3.0"
4345
},
4446
"suggest": {
4547
},
@@ -52,8 +54,5 @@
5254
"LERN": "Tylercd100\\LERN\\Facades\\LERN"
5355
}
5456
}
55-
},
56-
"repositories": [
57-
58-
]
57+
}
5958
}

config/lern.php

+14-24
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
return [
44

5-
/**
6-
* To avoid infinite loops that generate thousands of records/notifications in an instant
5+
/**
6+
* To avoid infinite loops that generate thousands of records/notifications in an instant
77
* Please make sure you use a Cache driver that is persistant such as redis, memcache, file, etc
8-
*
8+
*
99
* Value is in seconds.
1010
*/
11-
'ratelimit' => 1,
11+
'ratelimit' => 1,
1212

1313
'record'=>[
1414
/**
@@ -30,7 +30,7 @@
3030
* Database table to use
3131
*/
3232
'table'=>'vendor_tylercd100_lern_exceptions',
33-
33+
3434
/**
3535
* Information to store
3636
*/
@@ -71,12 +71,12 @@
7171
* The log level to use when notifying
7272
*/
7373
'log_level' => 'critical', //Options are: debug, info, notice, warning, error, critical, alert, emergency.
74-
74+
7575
/**
7676
* When using the default message body this will also include the stack trace
7777
*/
7878
'includeExceptionStackTrace' => true,
79-
79+
8080
/**
8181
* mail, pushover, slack, etc...
8282
*/
@@ -120,20 +120,17 @@
120120
],
121121

122122
/**
123-
* HipChat settings
123+
* Flowdock settings
124124
*/
125-
'hipchat'=>[
126-
'token' => env('HIPCHAT_APP_TOKEN'),
127-
'room' => 'room',
128-
'name' => 'name',
129-
'notify'=> true,
125+
'flowdock'=>[
126+
'token' => env('FLOWDOCK_APP_TOKEN'),
130127
],
131128

132129
/**
133-
* Flowdock settings
130+
* Sentry settings
134131
*/
135-
'flowdock'=>[
136-
'token' => env('FLOWDOCK_APP_TOKEN'),
132+
'sentry'=>[
133+
'dsn' => env('SENTRY_DSN'),
137134
],
138135

139136
/**
@@ -161,14 +158,7 @@
161158
'secret' => env('TWILIO_AUTH_SECRET'),
162159
'to' => env('TWILIO_TO'),
163160
'from' => env('TWILIO_FROM'),
164-
],
165-
166-
/**
167-
* Raven settings
168-
*/
169-
'raven'=>[
170-
'dsn' => env('RAVEN_DSN'),
171161
]
172162
],
173-
163+
174164
];

src/Components/Component.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tylercd100\LERN\Components;
44

5-
use Exception;
5+
use Throwable;
66
use Illuminate\Support\Facades\Cache;
77
use Carbon\Carbon;
88

@@ -23,10 +23,10 @@ abstract class Component {
2323
/**
2424
* Determine if the exception is in the "do not handle" list.
2525
*
26-
* @param \Exception $e
26+
* @param \Throwable $e
2727
* @return bool
2828
*/
29-
protected function shouldntHandle(Exception $e) {
29+
protected function shouldntHandle(Throwable $e) {
3030
$dontHandle = array_merge($this->dontHandle, $this->absolutelyDontHandle);
3131

3232
foreach ($dontHandle as $type) {
@@ -46,10 +46,10 @@ protected function shouldntHandle(Exception $e) {
4646
/**
4747
* Returns the cache key for the exception with the current component
4848
*
49-
* @param \Exception $e
49+
* @param \Throwable $e
5050
* @return string
5151
*/
52-
protected function getCacheKey(Exception $e)
52+
protected function getCacheKey(Throwable $e)
5353
{
5454
return "LERN::".static::class."::".get_class($e);
5555
}

0 commit comments

Comments
 (0)