From 5e859821339d3d22c5195b9c00afba0c3d3450b6 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Tue, 24 Jan 2017 11:22:01 -0700 Subject: [PATCH 1/6] Change share to singleton The `share` method has been removed in Laravel 5.4. Documentation recommends using the `singleton` method instead. --- src/RollbarServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RollbarServiceProvider.php b/src/RollbarServiceProvider.php index fdace1e..34e760d 100644 --- a/src/RollbarServiceProvider.php +++ b/src/RollbarServiceProvider.php @@ -39,7 +39,7 @@ public function register() $app = $this->app; - $this->app['RollbarNotifier'] = $this->app->share(function ($app) { + $this->app['RollbarNotifier'] = $this->app->singleton(function ($app) { // Default configuration. $defaults = [ 'environment' => $app->environment(), @@ -59,7 +59,7 @@ public function register() return $rollbar; }); - $this->app['Jenssegers\Rollbar\RollbarLogHandler'] = $this->app->share(function ($app) { + $this->app['Jenssegers\Rollbar\RollbarLogHandler'] = $this->app->singleton(function ($app) { $level = getenv('ROLLBAR_LEVEL') ?: $app['config']->get('services.rollbar.level', 'debug'); return new RollbarLogHandler($app['RollbarNotifier'], $app, $level); From 389f3810207b62500a3bfbeed65194f713a72620 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Tue, 24 Jan 2017 11:29:21 -0700 Subject: [PATCH 2/6] Require PHPUnit for testing --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 087cd6a..f39a902 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "require-dev": { "orchestra/testbench": "^3.0", "mockery/mockery": "^0.9", - "satooshi/php-coveralls": "^1.0" + "satooshi/php-coveralls": "^1.0", + "phpunit/phpunit": "~5.0" }, "autoload": { "psr-4": { From 15b0ff0a5c25615f977d71bccf5462e3bae27d61 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Tue, 24 Jan 2017 11:29:49 -0700 Subject: [PATCH 3/6] Correct singleton method format --- src/RollbarServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RollbarServiceProvider.php b/src/RollbarServiceProvider.php index 34e760d..f1ef91c 100644 --- a/src/RollbarServiceProvider.php +++ b/src/RollbarServiceProvider.php @@ -39,7 +39,7 @@ public function register() $app = $this->app; - $this->app['RollbarNotifier'] = $this->app->singleton(function ($app) { + $this->app->singleton('RollbarNotifier', function ($app) { // Default configuration. $defaults = [ 'environment' => $app->environment(), @@ -59,7 +59,7 @@ public function register() return $rollbar; }); - $this->app['Jenssegers\Rollbar\RollbarLogHandler'] = $this->app->singleton(function ($app) { + $this->app->singleton('Jenssegers\Rollbar\RollbarLogHandler', function ($app) { $level = getenv('ROLLBAR_LEVEL') ?: $app['config']->get('services.rollbar.level', 'debug'); return new RollbarLogHandler($app['RollbarNotifier'], $app, $level); From 0cc95d8fe196da9fca107b12001ecbaba0591b26 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Tue, 24 Jan 2017 11:34:50 -0700 Subject: [PATCH 4/6] Need PHPUnit 4 for older PHP versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f39a902..32fcf64 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "orchestra/testbench": "^3.0", "mockery/mockery": "^0.9", "satooshi/php-coveralls": "^1.0", - "phpunit/phpunit": "~5.0" + "phpunit/phpunit": "~4.0|~5.0" }, "autoload": { "psr-4": { From 53cb8d1dd438cef7509577912a14cbb621ef8715 Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Tue, 24 Jan 2017 13:12:38 -0700 Subject: [PATCH 5/6] Support 5.4 log listen callback Laravel 5.4 returns a single MessageLogged instance instead of 3 separate arguments. --- src/RollbarServiceProvider.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/RollbarServiceProvider.php b/src/RollbarServiceProvider.php index f1ef91c..7937fca 100644 --- a/src/RollbarServiceProvider.php +++ b/src/RollbarServiceProvider.php @@ -22,7 +22,20 @@ public function boot() $app = $this->app; // Listen to log messages. - $app['log']->listen(function ($level, $message, $context) use ($app) { + $app['log']->listen(function () use ($app) { + $args = func_get_args(); + + // Laravel 5.4 returns a MessageLogged instance only + if (count($args) == 1) { + $level = $args[0]->level; + $message = $args[0]->message; + $context = $args[0]->context; + } else { + $level = $args[0]; + $message = $args[1]; + $context = $args[2]; + } + $app['Jenssegers\Rollbar\RollbarLogHandler']->log($level, $message, $context); }); } From 684cc267b05fda9b769cc9ad9cb5a874757610bf Mon Sep 17 00:00:00 2001 From: Doug Sisk Date: Tue, 24 Jan 2017 13:17:41 -0700 Subject: [PATCH 6/6] Use composer installed PHPUnit on Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ca355ac..254c2be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: script: - mkdir -p build/logs - - phpunit --coverage-clover build/logs/clover.xml + - vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_success: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then php vendor/bin/coveralls -v; fi;'