Skip to content

[WIP] Support for laravel 5.6 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ dist: trusty
php:
- 7.2
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
- hhvm
- nightly

matrix:
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@ For bug reports, please [open an issue on GitHub](https://github.com/rollbar/rol

## Testing
Tests are in `tests`.
To run the tests: `composer test`
To fix code style issues: `composer fix`
* To run the tests: `composer test`
* To fix code style issues: `composer fix`

## Docker
Docker binaries are located in `./bin` and can be run by simply executing `bin/phpunit` for example.
* To run tests: `bin/phpunit`
* To run code sniffer: `bin/phpcs` or `bin/phpcbf`
* To run all supported versions: `bin/phpunit-versions`
* To run composer : `bin/composer install` OR `bin/composer update`
8 changes: 8 additions & 0 deletions bin/composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

docker run --rm --interactive --tty \
-e "TERM=xterm-256color" \
-v $PWD:/app \
composer "$@"
11 changes: 11 additions & 0 deletions bin/phpcbf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

docker run -it --rm \
-e "TERM=xterm-256color" \
-v "$PWD":/usr/src \
-w /usr/src \
php:7.2-cli-alpine \
vendor/bin/phpcbf --standard=PSR1,PSR2 src tests

11 changes: 11 additions & 0 deletions bin/phpcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

docker run -it --rm \
-e "TERM=xterm-256color" \
-v "$PWD":/usr/src \
-w /usr/src \
php:7.2-cli-alpine \
vendor/bin/phpcs --standard=PSR1,PSR2 src tests

11 changes: 11 additions & 0 deletions bin/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

docker run -it --rm \
-e "TERM=xterm-256color" \
-v "$PWD":/usr/src \
-w /usr/src \
php:7.2-cli-alpine \
vendor/bin/phpunit --coverage-clover build/logs/clover.xml

15 changes: 15 additions & 0 deletions bin/phpunit-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

declare -a versions=("7.1" "7.2")

for version in "${versions[@]}"
do
docker run -it --rm \
-e "TERM=xterm-256color" \
-v "$PWD":/usr/src \
-w /usr/src \
php:"$version"-cli-alpine \
vendor/bin/phpunit "$@"
done
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rollbar/rollbar-laravel",
"name": "ethical-jobs/rollbar-laravel",
"description": "Rollbar error monitoring integration for Laravel projects",
"keywords": ["laravel", "rollbar", "monitoring", "error", "logging"],
"homepage": "https://github.com/rollbar/rollbar-php-laravel",
Expand All @@ -16,16 +16,16 @@
}
],
"require": {
"php": ">=5.4",
"illuminate/support": "^4.0|^5.0",
"php": ">=7.0",
"illuminate/support": "^5.0",
"rollbar/rollbar": "^1"
},
"require-dev": {
"orchestra/testbench": "~3.0",
"orchestra/testbench": "~3.6",
"mockery/mockery": "^0.9",
"satooshi/php-coveralls": "^1.0",
"squizlabs/php_codesniffer": "2.*",
"phpunit/phpunit": "~4.0|~5.0"
"squizlabs/php_codesniffer": "3.*",
"phpunit/phpunit": "~7.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="true"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Test Suite">
Expand Down
3 changes: 2 additions & 1 deletion src/Facades/Rollbar.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace Rollbar\Laravel\Facades;

use Illuminate\Support\Facades\Facade;
use Rollbar\Laravel\RollbarLogHandler;

class Rollbar extends Facade
{
Expand All @@ -11,6 +12,6 @@ class Rollbar extends Facade
*/
protected static function getFacadeAccessor()
{
return 'Rollbar\Laravel\RollbarLogHandler';
return RollbarLogHandler::class;
}
}
52 changes: 38 additions & 14 deletions src/RollbarServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php namespace Rollbar\Laravel;

use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
use Rollbar\Rollbar;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
use Rollbar\Laravel\RollbarLogHandler;
use Rollbar\RollbarLogger;
use Rollbar\Rollbar;

class RollbarServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -41,7 +43,7 @@ public function boot()
$context = $args[2];
}

$app['Rollbar\Laravel\RollbarLogHandler']->log($level, $message, $context);
$app[RollbarLogHandler::class]->log($level, $message, $context);
});
}

Expand All @@ -55,9 +57,7 @@ public function register()
return;
}

$app = $this->app;

$this->app->singleton('Rollbar\RollbarLogger', function ($app) {
$this->app->singleton(RollbarLogger::class, function ($app) {

$defaults = [
'environment' => $app->environment(),
Expand All @@ -66,8 +66,10 @@ public function register()
'handle_error' => true,
'handle_fatal' => true,
];
$config = array_merge($defaults, $app['config']->get('services.rollbar', []));
$config['access_token'] = getenv('ROLLBAR_TOKEN') ?: $app['config']->get('services.rollbar.access_token');

$config = array_merge($defaults, $app['config']->get('logging.channels.rollbar', []));

$config['access_token'] = static::config('access_token');

if (empty($config['access_token'])) {
throw new InvalidArgumentException('Rollbar access token not configured');
Expand All @@ -82,11 +84,11 @@ public function register()
return Rollbar::logger();
});

$this->app->singleton('Rollbar\Laravel\RollbarLogHandler', function ($app) {
$this->app->singleton(RollbarLogHandler::class, function ($app) {

$level = getenv('ROLLBAR_LEVEL') ?: $app['config']->get('services.rollbar.level', 'debug');
$level = static::config('level', 'debug');

return new RollbarLogHandler($app['Rollbar\RollbarLogger'], $app, $level);
return new RollbarLogHandler($app[RollbarLogger::class], $app, $level);
});
}

Expand All @@ -95,12 +97,34 @@ public function register()
*
* @return boolean
*/
public function stop()
public function stop() : bool
{
$level = getenv('ROLLBAR_LEVEL') ?: $this->app->config->get('services.rollbar.level', null);
$token = getenv('ROLLBAR_TOKEN') ?: $this->app->config->get('services.rollbar.access_token', null);
$level = static::config('level');

$token = static::config('token');

$hasToken = empty($token) === false;

return $hasToken === false || $level === 'none';
}

/**
* Return a rollbar logging config
*
* @param array|string $key
* @param mixed $default
* @return mixed
*/
protected static function config($key = '', $default = null)
{
$envKey = 'ROLLBAR_'.strtoupper($key);

if ($envKey === 'ROLLBAR_ACCESS_TOKEN') {
$envKey = 'ROLLBAR_TOKEN';
}

$logKey = empty($key) ? 'logging.channels.rollbar' : "logging.channels.rollbar.$key";

return getenv($envKey) ?: Config::get($logKey, $default);
}
}
Loading