samplemeapp/airbrake-bundle

PHP 7, Symfony 2.8+ bundle for sending errors into Airbrake

1.2.0 2016-12-14 11:48 UTC

This package is not auto-updated.

Last update: 2022-10-15 08:52:18 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Our Airbrake bundle enables development teams to quickly add support for error/exception reporting via airbrake.io or errbit.com, for their PHP7 packages and projects built on Symfony 2.8+.

The bundle supports a number of customisation parameters, PSR-4 autoloading, is PSR-2 compliant and has been well tested through automated tests, as well as being used in various microservices within the SampleMe ecosystem.

Install

Via Composer

$ composer require samplemeapp/airbrake-bundle

Enable the bundle in your AppKernel, present in: app/AppKernel.php.

$bundles = [
    new SM\AirbrakeBundle\SMAirbrakeBundle(),
]

Configuration

In order to start reporting all exceptions to airbrake.io, add the following configuration to your app/config/config.yml:

sm_airbrake:
    project_id: 'your-project-id'
    project_key: 'your-project-key'
    listener_enabled: true

Usage

If you want to manually interact with the Airbrake service, it is also exposed as a container service:

$exception = new \Exception('Something went wrong');
$container->get('sm_airbrake.airbrake.service')->notify($exception);

One use case in which you may want to follow the approach above is if you do not want the listener to trigger on every exception, or if you want to add your own business logic to when the service is called.

For more API information, see SM\AirbrakeBundle\Service\AirbrakeService.

Configuration Reference

The following configuration parameters are also available for the bundle:

sm_airbrake:
    # The ID of the project.
    project_id: string #project-id
    
    # The key of the project.
    project_key: string #project-key
    
    # The HTTP client to use in order to contact the host.
    # Defaults to 'default'.
    http_client: string #default/curl/guzzle/
    
    # Whether or not to register a global exception instance, retrievable via Instance::notify($e);
    # Defaults to false.
    global_exception_instance: boolean #true/false
    
    # Whether or not to register a global error and exception handler.
    # Defaults to false.
    global_error_and_exception_handler: boolean #true/false
    
    # The host to which the bundle should connect.
    # Defaults to 'api.airbrake.io'.
    host: string #api.airbrake.io/errbit.internal
    
    # Exception class paths that should be ignored. Useful for not overloading your logs.
    # Defaults to [].
    ignored_exceptions:
        - "Symfony\\Component\\HttpKernel\\Exception\\HttpException"
        - "Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException"
        
    # The root directory that should be reported to the host
    # Defaults to the 'kernel.root_dir' parameter
    root_directory: string
    
    # The environment that should be reported to the host
    # Defaults to 'undefined'
    environment: string 
    
    # The app version that should be reported to the host
    # Defaults to 'undefined' or the value in the /VERSION file present in the root directory of the project.
    app_version: string
    
    # Enables or disables the 'kernel.exception' event listener.
    # Defaults to false.
    listener_enabled: boolean #true/false

Testing

$ composer test

PSR-2 Compatibility

$ composer check-styles
$ composer fix-styles

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email petre@dreamlabs.ro instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.