2017 © Pedro Peláez
 

yii2-extension yii2-phpbrake

Yii2 Phpbrake integration

image

juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  • Friday, July 13, 2018
  • by juanisorondo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,988 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 39 % Grown

The README.md

yii2-airbrake

Airbrake integration for Yii2, which wraps around official Airbrake PHP library (airbrake/phpbrake)., (*1)

Installation

composer require biller/yii2-airbrake

Usage

While it is not explicitly required, it is recommended to configure the AirbrakeService as a component in environment (or even common) configuration, so it is easily accessible from the whole application ( using i.e. Yii::$app->get('airbrakeService'))., (*2)

return [
    // ...
    'components' => [
        // ...
        'airbrakeService' => [
            'class' => biller\phpbrake\AirbrakeService::class,

            'enabled' => true, // default TRUE

            'projectId' => 'YOUR_PROJECT_ID',
            'projectKey' => 'YOUR_PROJECT_KEY',

            'environment' => YII_ENV, // default NULL
            'appVersion' => [your-app-version], // default NULL
            'rootDirectory' => [source-root-directory], // default NULL
            'host' => [api-endpoint-host], // default "api.airbrake.io"
            'httpClient' => [http-client-type], // default "default"

            'setGlobalInstance' => [boolean], // default TRUE
            'setErrorHandler' => [boolean], // default FALSE

            'filters' => [ // default NULL
                // 'PHPSESSID' and '_csrf' parameters should not be transferred to airbrake
                [
                    'class' => biller\phpbrake\ParamsFilter::class,
                    'params' => ['PHPSESSID', '_csrf'],
                ],
            ],
        ],
    ],
];

Configuration options marked with asterisk are required, all other options are optional., (*3)

  • rootDirectory: should be set to your sources root to allow shortening of file paths
  • httpClient: specifies type of HTTP client to use and can be configured as:
    • AirbrakeService::CLIENT_DEFAULT
    • AirbrakeService::CLIENT_GUZZLE
    • AirbrakeService::CLIENT_CURL
  • setGlobalInstance: if set to true, current instance will be set as global instance
  • setErrorHandler: if set to true, current instance will be set as PHP run-time unhandled exception handler
  • filters: array of callables providing notice pre-processing

For additional information about the API, please consult official Airbrake PHP library documentation., (*4)

AirbrakeFilterFactory

Factory class that can be used to create various filtering rules., (*5)

AirbrakeFilterFactory::createParamsFilter(array $params, $replacement = 'FILTERED')

Method will create filtering callable that filters parameters, specified by $params and replaces it with specified $replacement. Example usage is available above., (*6)

Console Support

Integration can be added to Yii console, where it currently provides a command to track deployment (new feature in Airbrake API 4 that allows to mark error timeline with deployments)., (*7)

Usage

To use ConsoleController, AirbrakeService should be configured as component., (*8)

import enscope\Yii2\Ext\Airbrake\ConsoleController;

return [
    // ...
    'controllerMap' => [
        // ...
        'airbrake' => [
            'class' => ConsoleController::class,
            'airbrakeService' => [component-name], // default "airbrakeService"
        ],
    ],
];

While parameters can be hard-coded in configuration, console controller supports inferParameters, username , revision and repository parameters to be set by arguments on command line., (*9)

  • airbrakeService: name of the component or initialized instance
  • inferParameters: if TRUE, repository and revision are discovered using exec() calls
  • revision: identifier of the revision, discovered by git rev-parse HEAD if infer allowed
  • repository: identifier of the repository, discovered by git remote get-url origin if infer allowed
  • username: name of the user tracking deploy (default "system")

Logging Target

You can configure Yii2 logger to log errors automatically to Airbrake Service., (*10)

Usage

To use ConsoleController, AirbrakeService should be configured as component., (*11)

return [
    'components' => [
        'log' => [
            'targets' => [
                [
                    'class' => biller\phpbrake\AirbrakeTarget::class,
                    'levels' => ['error'],
                ],
            ],
        ],
    ],
];

The target currently does not expose any other configuration options other then those exposed by yii\log\Target, except the service component:, (*12)

  • airbrakeService: name of the component or initialized instance

License

Yii2 Airbrake integration is licensed under The MIT License (MIT) as is the original PHP Airbrake library and follows the versioning of that library., (*13)

The Versions

13/07 2018

dev-master

9999999-dev https://github.com/juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  Sources   Download

MIT MIT License

The Requires

 

extension logging yii2 airbrake error reporting

13/07 2018

v0.2.2

0.2.2.0 https://github.com/juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  Sources   Download

MIT

The Requires

 

extension logging yii2 airbrake error reporting

09/04 2018

v0.2.1

0.2.1.0 https://github.com/juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  Sources   Download

MIT

The Requires

 

extension logging yii2 airbrake error reporting

13/03 2018

v0.2.0

0.2.0.0 https://github.com/juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  Sources   Download

MIT

The Requires

 

extension logging yii2 airbrake error reporting

25/10 2017

v0.1.1

0.1.1.0 https://github.com/juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  Sources   Download

MIT License

The Requires

 

extension logging yii2 airbrake error reporting

23/10 2017

v0.1.0

0.1.0.0 https://github.com/juanisorondo/yii2-phpbrake

Yii2 Phpbrake integration

  Sources   Download

MIT License

The Requires

 

extension logging yii2 airbrake error reporting