Skip to content

Commit ddcd00b

Browse files
PHP 8.0 support 🚀 and more (#7)
* update composer for Laravel 6.0.4 * update composer for Laravel ^6.0 * update composer for Laravel ^7.0 * Update composer.json to use Laravel 6, 7 and 8 * Update Travis CI config to use PHP >= 7.2 * Remove HipChat and Raven drivers because Monolog 2.0 removed them * Laravel >= 8.0 doesn't support PHP 7.2 Update Travis CI config to ignore errors on PHP 7.2 * Tweak Travis CI config To ignore errors only when testing with PHP 7.2 and Laravel 8 * Fix Travis CI config To allow failures only when testing with PHP 7.2 and Laravel 8 * Clean Travis CI config * Use 'next' branch for monolog-mailgun and monolog-sms * 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 * Fix Sentry driver Fix commit fd624a1 * Run tests with PHP 8.0 on Travis CI * Clean Composer file Use the upcoming 'tylercd100/monolog-mailgun' 3.0.0 and 'tylercd100/monolog-sms' 2.0.0 versions Co-authored-by: Robbie Love <[email protected]>
1 parent 3cf26f6 commit ddcd00b

13 files changed

+78
-161
lines changed

‎.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ language: php
22

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

69
env:
710
matrix:
@@ -10,7 +13,7 @@ env:
1013

1114
before_script:
1215
- travis_retry composer self-update
13-
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
16+
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist
1417

1518
script:
1619
- 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 `laravel-notify` 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
### 3.0.0
614
- Updated for Laravel 6
715

‎README.md

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

2423
## Version Compatibility
@@ -30,7 +29,9 @@ Currently supported notification channels via [Monolog](https://github.com/Selda
3029
5.3.x | 1.x
3130
5.4.x | 1.x
3231
5.5.x | 2.x
33-
6.x | 3.x
32+
6.x | 3.x and 4.x
33+
7.x | 4.x
34+
8.x | 4.x
3435

3536
## Installation
3637

@@ -66,14 +67,13 @@ Notify::info("This is a info message with context!",['user'=>$user, 'data'=>$dat
6667
## Other Features
6768
Laravel Notify also exposes extra Facades. To use them you will need to add them to your `config/app.php` file in your aliases array.
6869
```php
69-
"HipChat" => Tylercd100\Notify\Facades\HipChat::class,
7070
"Pushover" => Tylercd100\Notify\Facades\Pushover::class,
7171
"Flowdock" => Tylercd100\Notify\Facades\Flowdock::class,
7272
"FleepHook" => Tylercd100\Notify\Facades\FleepHook::class,
7373
"Slack" => Tylercd100\Notify\Facades\Slack::class,
7474
"Plivo" => Tylercd100\Notify\Facades\Plivo::class,
7575
"Twilio" => Tylercd100\Notify\Facades\Twilio::class,
76-
"Raven" => Tylercd100\Notify\Facades\Raven::class,
76+
"Sentry" => Tylercd100\Notify\Facades\Sentry::class,
7777
"Mailgun" => Tylercd100\Notify\Facades\Mailgun::class,
7878
```
7979
And then use them like this

‎composer.json

+15-10
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,27 @@
2525
"Tylercd100\\Notify\\Tests\\": "tests/"
2626
}
2727
},
28-
"minimum-stability": "stable",
28+
"minimum-stability": "dev",
29+
"prefer-stable": true,
2930
"require": {
30-
"illuminate/support": "^6.0",
31-
"monolog/monolog": "^1.11",
32-
"php": "^7.2",
31+
"illuminate/support": "^6.0|^7.0|^8.0",
32+
"monolog/monolog": "^2.0",
33+
"php": "^7.2|^8.0",
3334
"psr/log": "^1.0",
34-
"tylercd100/monolog-mailgun": "^2.0",
35-
"tylercd100/monolog-sms":"^1.2"
35+
"tylercd100/monolog-mailgun": "^3.0",
36+
"tylercd100/monolog-sms":"^2.0"
3637
},
3738
"require-dev": {
38-
"sentry/sentry": "~1.7",
39-
"phpunit/phpunit": "^8.0",
40-
"orchestra/testbench": "^4.0"
39+
"sentry/sentry": "dev-php8-support",
40+
"symfony/options-resolver": "^5.1",
41+
"http-interop/http-factory-guzzle": "^1.0.0",
42+
"php-http/guzzle7-adapter": "^0.2.0",
43+
"phpunit/phpunit": "^8.4|^9.3.3",
44+
"mockery/mockery": "~1.3.3|^1.4.2",
45+
"orchestra/testbench": "^4.0|^5.0|^6.0"
4146
},
4247
"suggest": {
43-
"sentry/sentry": "Required to use the Raven driver for Sentry (~1.7)."
48+
"sentry/sentry": "Required to use the Sentry driver (~3.0)."
4449
},
4550
"extra": {
4651
"providers": [

‎config/notify.php

+7-17
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,18 @@
4646
],
4747

4848
/**
49-
* HipChat settings
49+
* Flowdock settings
5050
*/
51-
'hipchat'=>[
52-
'token' => env('HIPCHAT_APP_TOKEN'),
53-
'room' => 'room',
54-
'name' => 'name',
55-
'notify'=> true,
51+
'flowdock'=>[
52+
'token' => env('FLOWDOCK_APP_TOKEN'),
5653
],
5754

5855
/**
59-
* Flowdock settings
56+
* Sentry settings
6057
*/
61-
'flowdock'=>[
62-
'token' => env('FLOWDOCK_APP_TOKEN'),
58+
'sentry'=>[
59+
'dsn' => env('SENTRY_DSN'),
60+
'level' => 'info',
6361
],
6462

6563
/**
@@ -89,13 +87,5 @@
8987
'to' => env('TWILIO_TO'),
9088
'from' => env('TWILIO_FROM'),
9189
'limit' => 160,
92-
],
93-
94-
/**
95-
* Raven settings
96-
*/
97-
'raven'=>[
98-
'dsn' => env('RAVEN_DSN'),
99-
'level' => 'info',
10090
]
10191
];

‎src/Drivers/Raven.php

-16
This file was deleted.

‎src/Drivers/HipChat.php renamed to ‎src/Drivers/Sentry.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
use Tylercd100\Notify;
66

7-
class HipChat extends Base
7+
class Sentry extends Base
88
{
99
/**
1010
* Returns a list of driver names to load
1111
* @return array An array of drivers to use
1212
*/
13-
protected function getDrivers(){
14-
return ['hipchat'];
13+
protected function getDrivers()
14+
{
15+
return ['sentry'];
1516
}
16-
}
17+
}

‎src/Facades/HipChat.php

-21
This file was deleted.

‎src/Facades/Raven.php renamed to ‎src/Facades/Sentry.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* @see \Illuminate\Filesystem\Filesystem
99
*/
10-
class Raven extends Facade
10+
class Sentry extends Facade
1111
{
1212
/**
1313
* Get the registered name of the component.
@@ -16,6 +16,6 @@ class Raven extends Facade
1616
*/
1717
protected static function getFacadeAccessor()
1818
{
19-
return 'notify-raven';
19+
return 'notify-sentry';
2020
}
21-
}
21+
}

‎src/Factories/MonologHandlerFactory.php

+10-41
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class MonologHandlerFactory
1919
*/
2020
public static function create($name, array $config = [], $title = null){
2121
$handler = call_user_func([MonologHandlerFactory::class,$name], $config, $title);
22-
22+
2323
// Keep newline characters
24-
$format = ['fleephook', 'hipchat', 'mail', 'mailgun', 'pushover', 'raven', 'slack'];
25-
24+
$format = ['fleephook', 'mail', 'mailgun', 'pushover', 'slack', 'sentry'];
25+
2626
if(in_array($name, $format)) {
2727
$handler->setFormatter(new LineFormatter(null, null, true));
2828
}
@@ -203,22 +203,24 @@ protected static function twilio(array $config = [], $title = null){
203203
}
204204

205205
/**
206-
* Returns a RavenHandler
206+
* Returns a SentryHandler
207207
* @param array $config An array of config values to use
208208
* @param string $title The title/subject to use
209-
* @return \Monolog\Handler\RavenHandler
209+
* @return \Sentry\Monolog\Handler
210210
*/
211-
protected static function raven(array $config = [], $title = null){
211+
protected static function sentry(array $config = [], $title = null)
212+
{
212213
$defaults = [
213214
'dsn' => null,
214215
'level' => Logger::ERROR,
215216
'bubble' => true,
216217
];
217218

218219
$c = array_merge($defaults, $config);
220+
$client = \Sentry\ClientBuilder::create(Arr::only($c, 'dsn'))->getClient();
219221

220-
return new \Monolog\Handler\RavenHandler(
221-
new \Raven_Client($c['dsn'], Arr::except($c, ['dsn'])),
222+
return new \Sentry\Monolog\Handler(
223+
new \Sentry\State\Hub($client),
222224
$c['level'],
223225
$c['bubble']
224226
);
@@ -255,39 +257,6 @@ protected static function slack(array $config = [], $title = null){
255257
$c['includeContextAndExtra']);
256258
}
257259

258-
/**
259-
* Returns a HipChatHandler
260-
* @param array $config An array of config values to use
261-
* @param string $title The title/subject to use
262-
* @return \Monolog\Handler\HipChatHandler
263-
*/
264-
protected static function hipchat(array $config = [], $title = null){
265-
$defaults = [
266-
'name' => 'Monolog',
267-
'notify' => false,
268-
'level' => Logger::DEBUG,
269-
'bubble' => true,
270-
'useSSL' => true,
271-
'format' => 'text',
272-
'host' => 'api.hipchat.com',
273-
'version' => 'v1'
274-
];
275-
276-
$c = array_merge($defaults,$config);
277-
278-
return new \Monolog\Handler\HipChatHandler(
279-
$c['token'],
280-
$c['room'],
281-
$c['name'],
282-
$c['notify'],
283-
$c['level'],
284-
$c['bubble'],
285-
$c['useSSL'],
286-
$c['format'],
287-
$c['host'],
288-
$c['version']);
289-
}
290-
291260
/**
292261
* Creates Mail Monolog Handler
293262
* @param array $config An array of config values to use

‎src/Providers/NotifyServiceProvider.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
use Tylercd100\Notify\Drivers\FleepHook;
77
use Tylercd100\Notify\Drivers\Flowdock;
88
use Tylercd100\Notify\Drivers\FromConfig;
9-
use Tylercd100\Notify\Drivers\HipChat;
109
use Tylercd100\Notify\Drivers\Mail;
1110
use Tylercd100\Notify\Drivers\Mailgun;
1211
use Tylercd100\Notify\Drivers\Plivo;
1312
use Tylercd100\Notify\Drivers\Pushover;
14-
use Tylercd100\Notify\Drivers\Raven;
1513
use Tylercd100\Notify\Drivers\Slack;
14+
use Tylercd100\Notify\Drivers\Sentry;
1615
use Tylercd100\Notify\Drivers\Twilio;
1716

1817
class NotifyServiceProvider extends ServiceProvider
@@ -24,12 +23,11 @@ public function register() {
2423
'notify' => FromConfig::class,
2524
'notify-fleephook' => FleepHook::class,
2625
'notify-flowdock' => Flowdock::class,
27-
'notify-hipchat' => HipChat::class,
2826
'notify-mail' => Mail::class,
2927
'notify-mailgun' => Mailgun::class,
3028
'notify-plivo' => Plivo::class,
3129
'notify-pushover' => Pushover::class,
32-
'notify-raven' => Raven::class,
30+
'notify-sentry' => Sentry::class,
3331
'notify-slack' => Slack::class,
3432
'notify-twilio' => Twilio::class,
3533
];
@@ -41,7 +39,7 @@ public function boot()
4139
{
4240
$this->publishes([
4341
__DIR__ . '/../../config/notify.php' => base_path('config/notify.php'),
44-
]);
42+
]);
4543
}
4644

4745
private function registerSingletonsFromMap($map){
@@ -51,4 +49,4 @@ private function registerSingletonsFromMap($map){
5149
});
5250
}
5351
}
54-
}
52+
}

0 commit comments

Comments
 (0)