Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasvargiu committed Aug 31, 2019
2 parents 9b6e1d0 + 95a82a9 commit d9d9e6d
Show file tree
Hide file tree
Showing 45 changed files with 4,001 additions and 3,237 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
phpunit.xml
clover.xml
/vendor/
/phpunit.xml
/clover.xml
/.php_cs.cache
22 changes: 13 additions & 9 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
* Additional rules or rules to override.
* These rules will be added to default rules or will override them if the same key already exists.
*/

$additionalRules = [];
$rules = new Facile\CodingStandards\DefaultRules($additionalRules);
$rulesProvider = new Facile\CodingStandards\Rules\CompositeRulesProvider([
new Facile\CodingStandards\Rules\DefaultRulesProvider(),
new Facile\CodingStandards\Rules\RiskyRulesProvider(),
new Facile\CodingStandards\Rules\ArrayRulesProvider($additionalRules),
]);

$config = PhpCsFixer\Config::create();
$config->setRules($rules->getRules());

$config->setUsingCache(false);
$config->setRiskyAllowed(false);
$config->setRules($rulesProvider->getRules());

$finder = PhpCsFixer\Finder::create();
$finder->in(array (
0 => 'src/',
0 => 'tests/',
));

/*
* You can set manually these paths:
*/
$autoloadPathProvider = new Facile\CodingStandards\AutoloadPathProvider();
$finder->in($autoloadPathProvider->getPaths());

$config->setFinder($finder);

Expand Down
28 changes: 20 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ cache:
directories:
- $HOME/.composer/cache
- vendor
- $HOME/.local

env:
global:
Expand All @@ -15,24 +14,34 @@ env:
matrix:
fast_finish: true
include:
- php: 7.0
- php: 7.1
env:
- DEPS=lowest
- php: 7.0
- php: 7.1
env:
- DEPS=latest
- php: 7.2
env:
- DEPS=lowest
- php: 7.2
env:
- EXECUTE_PHPSTAN_CHECK=true
- EXECUTE_CS_CHECK=true
- EXECUTE_TEST_SCRUTINIZER=true
- DEPS=locked
- php: 7.0
- php: 7.2
env:
- DEPS=latest
- php: 7.1
- php: 7.3
env:
- DEPS=lowest
- php: 7.1
- php: 7.3
env:
- DEPS=locked
- php: 7.1
- DEPS=latest
- php: 7.4snapshot
env:
- DEPS=lowest
- php: 7.4snapshot
env:
- DEPS=latest
- php: 7.2
Expand All @@ -47,15 +56,18 @@ matrix:
- php: nightly
env:
- DEPS=latest

allow_failures:
- php: nightly
- php: 7.4snapshot

install:
- if [[ $DEPS == 'locked' ]]; then travis_retry composer install $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi

script:
- if [[ EXECUTE_PHPSTAN_CHECK == 'true' ]]; then composer phpstan ; fi
- if [[ $EXECUTE_TEST_SCRUTINIZER == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover coverage.clover ; fi
- if [[ $EXECUTE_TEST_SCRUTINIZER != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then composer cs-check ; fi
Expand Down
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Change Log

## [0.7.2] - TBD
### Added
- Nothing
## [1.0.0] - TBD
### Changed
- Completely rewritten


## [0.7.1] - 2017-11-09
Expand Down
98 changes: 50 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Code Coverage](https://scrutinizer-ci.com/g/facile-it/sentry-module/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/facile-it/sentry-module/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/facile-it/sentry-module/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/facile-it/sentry-module/?branch=master)

This module allows integration with Raven Sentry Client into Zend Framework 2/3.
This module allows integration with Sentry Client into zend-framework 2/3 and zend-expressive.

## Installation

Expand All @@ -22,41 +22,38 @@ php composer.phar require facile-it/sentry-module
To configure an instance of the client you can do as below:

```php
//...

return [
'facile' => [
'sentry' => [
'dsn' => '', // Sentry Raven dsn
'raven_options' => [ // Sentry Raven options
'app_path' => '',
'release' => 'release-hash',
// ....
],
'raven_javascript_dsn' => '', // javascript sentry dsn
'raven_javascript_uri' => 'https://cdn.ravenjs.com/3.16.0/raven.min.js',
'raven_javascript_options' => [], // javascript sentry options
'inject_raven_javascript' => false, // should we inject sentry JS file and script?
'error_handler_options' => [ // Error Handler Listener options (read below)
'error_types' => null, // Error types to log, NULL will get value from error_reporting() function
'skip_exceptions' => [], // Exception class names to skip when loggin exceptions
'sentry' => [
'options' => [
'dsn' => '',
// other sentry options
// https://docs.sentry.io/error-reporting/configuration/?platform=php
],
'javascript' => [
'inject_script' => false,
'script' => [
'src' => 'https://browser.sentry-cdn.com/5.6.3/bundle.min.js',
'integrity' => 'sha384-/Cqa/8kaWn7emdqIBLk3AkFMAHBk0LObErtMhO+hr52CntkaurEnihPmqYj3uJho',
'crossorigin' => 'anonymous',
],
'stack_trace_options' => [
// We clean the backtrace when loggin messages removing last stacks from our library.
// You can add more namespaces to ignore when using some other
// libraries between the real log line and our library.
// "Facile\SentryModule" is already present in module's configuration.
'ignore_backtrace_namespaces' => [],
'options' => [
'dsn' => '',
// other sentry options
// https://docs.sentry.io/error-reporting/configuration/?platform=php
],
],
],
];
//...
```

Now you can use the client and the Raven client by retrieving it from the Service Locator.
Now you can use the client and the Hub by retrieving it from the Service Locator.

```php
$client = $this->getServiceLocator()->get(\Raven_Client::class);
use Sentry\HubInterface;

$hub = $this->getServiceLocator()->get(HubInterface::class);
```

### Error Handler Listener
Expand All @@ -74,30 +71,19 @@ If you want to use it you should register it in your application module.
namespace App;

use Facile\SentryModule\Listener\ErrorHandlerListener;
use Zend\EventManager\EventInterface;
use Zend\Mvc\MvcEvent;
use Raven_Client;

class Module
{
public function onBootstrap(EventInterface $e)
public function onBootstrap(MvcEvent $e): void
{
/* @var MvcEvent $e */
$application = $e->getApplication();
$container = $application->getServiceManager();
$eventManager = $application->getEventManager();

/** @var ErrorHandlerListener $errorHandlerListener */
$errorHandlerListener = $container->get(ErrorHandlerListener::class);
$errorHandlerListener->attach($eventManager);

// you can optionally register Raven_ErrorHandler
/** @var Raven_Client $client */
$client = $container->get(Raven_Client::class);
// $errorHandler = new \Raven_ErrorHandler($client);
// $errorHandler->registerErrorHandler();
// $errorHandler->registerExceptionHandler();
// $errorHandler->registerShutdownFunction();
}
}
```
Expand Down Expand Up @@ -137,15 +123,14 @@ return [
Usage:

```php

$logger->crit('Log this message');

// or with exceptions, to see the correct trace in sentry:
$e = new \RuntimeException('test-exception');
$logger->crit($e->getMessage(), ['exception' => $e]);
```

If you are interested on a PSR3 compatible log you can use [facile-it/sentry-psr-log](https://github.com/facile-it/sentry-psr-log).

### Javascript

This module can inject the javascript Raven client library and configure it for you.
Expand All @@ -155,20 +140,37 @@ This module can inject the javascript Raven client library and configure it for

// facile-sentry.module.local.php
return [
'facile' => [
'sentry' => [
'raven_javascript_dsn' => '', // (public dsn to use)
'raven_javascript_uri' => 'https://cdn.ravenjs.com/3.16.0/raven.min.js', // (default)
'raven_javascript_options' => [
'release' => 'release-hash',
'sentry' => [
'javascript' => [
'inject_script' => true, // enable it
'options' => [
'dsn' => '',
// other sentry options
// https://docs.sentry.io/error-reporting/configuration/?platform=php
],
// script options (defaults)
'script' => [
'src' => 'https://browser.sentry-cdn.com/5.6.3/bundle.min.js',
'integrity' => 'sha384-/Cqa/8kaWn7emdqIBLk3AkFMAHBk0LObErtMhO+hr52CntkaurEnihPmqYj3uJho',
'crossorigin' => 'anonymous',
],
'inject_raven_javascript' => true, // (default false)
]
]
],
],
];

```
In your layout:
```php
<?= $this->headScript() ?>
```

## Usage with zend-expressive

If you want to use with zend-expressive you should initialize the Sentry client and Hub.
You can simply retrieve the HubInterface service to initialize it.

```php
use Sentry\HubInterface;

$container->get(HubInterface::class);
```
56 changes: 34 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@
"zf2",
"zf3",
"zend",
"zend framework"
"zend framework",
"expressive"
],
"authors": [
{
"name": "Thomas Vargiu",
"email": "[email protected]"
}
],
"extra": {
"zf": {
"component": "Facile\\SentryModule",
"config-provider": "Facile\\SentryModule\\ConfigProvider"
}
},
"autoload": {
"psr-4": {
"Facile\\SentryModule\\": "src/"
Expand All @@ -36,30 +43,34 @@
}
},
"require": {
"php": "^7.0",
"sentry/sentry": "^1.7",
"zendframework/zend-stdlib": "^2.7.5 || ^3.0.1",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-mvc": "^2.7 || ^3.0",
"zendframework/zend-modulemanager": "^2.5.1",
"zendframework/zend-view": "^2.5.1",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"facile-it/sentry-common": "^0.2.0"
"php": "^7.1",
"ext-json": "*",
"sentry/sentry": "^2.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3"
},
"require-dev": {
"phpunit/phpunit": "^6.2",
"phpunit/phpunit": "^7.5 || ^8.0",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"zendframework/zend-log": "^2.9",
"zendframework/zend-router": "^2.6.2 || ^3.0",
"facile-it/facile-coding-standard": "dev-composer-plugin"
"zendframework/zend-modulemanager": "^2.5.1",
"zendframework/zend-mvc": "^2.7 || ^3.0",
"zendframework/zend-view": "^2.5.1",
"facile-it/facile-coding-standard": "^0.3.1",
"php-http/curl-client": "^2.0",
"phpstan/phpstan": "^0.11.15",
"friendsofphp/php-cs-fixer": "^2.15"
},
"suggest": {
"zendframework/zend-log:^2.9": "Install to use the log writer",
"facile-it/sentry-psr-log": "Allows psr log implementation"
"conflict": {
"container-interop/container-interop": "< 1.2",
"zendframework/zend-eventmanager": "< 2.6.2",
"zendframework/zend-log": "< 2.9",
"zendframework/zend-modulemanager": "< 2.5.1",
"zendframework/zend-mvc": "< 2.7",
"zendframework/zend-view": "< 2.5.1"
},
"extra": {
"zf": {
"module": "Facile\\SentryModule"
}
"suggest": {
"zendframework/zend-eventmanager": "Install to use the MVC error handler",
"zendframework/zend-log": "Install to use the log writer"
},
"scripts": {
"test": [
Expand All @@ -68,9 +79,10 @@
"ci-test": [
"@ci-phpunit"
],
"phpstan": "phpstan analyse .",
"phpunit": "phpunit",
"ci-phpunit": "phpunit --coverage-clover=coverage.clover",
"cs-check": "php-cs-fixer fix --dry-run --diff",
"cs-fix": "php-cs-fixer fix --diff"
"cs-check": "php-cs-fixer fix --dry-run --diff --allow-risky yes",
"cs-fix": "php-cs-fixer fix --diff --allow-risky yes"
}
}
Loading

0 comments on commit d9d9e6d

Please sign in to comment.