2017 © Pedro Peláez
 

library silex-raven

A Silex Service Provider for Raven

image

v-six/silex-raven

A Silex Service Provider for Raven

  • Tuesday, April 15, 2014
  • by v-six
  • Repository
  • 1 Watchers
  • 1 Stars
  • 318 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

silex-raven

A basic Silex service provider for PHP client for Sentry : getsentry/raven-php., (*1)

Installation

The recommended way to install silex-raven is through Composer. Just create a composer.json file and run the php composer.phar install command to install it:, (*2)

{
    "require": {
        "v-six/silex-raven": "0.1.*"
    }
}

Alternatively, you can download the silex-raven.zip file and extract it., (*3)

Usage

$app->register(new SilexRaven\RavenServiceProvider(),
    array(
        'raven.dsn' => 'http://public:secret@example.com/1',
        'raven.options' => array(
            'logger' => 'my-logger-name' // Set custom logger name
        )
        'raven.handle' => array(
            'exceptions' => false, // Disable exceptions handler
            'errors' => true, // Enable errors handler
            'fatal_errors' => true, // Enable fatal_errors handler
        )
    )
);

If necessary, set your own options in raven.options (see Raven documentation). All handlers are registered by default, you can disable them by setting corresponding configuration input to false in raven.handle., (*4)

Custom

You can easily capture an error or an exception with the following :, (*5)

// Capture an error
$app['raven']->captureMessage('Oops !');

// Capture an exception
$app['raven']->captureException(new \Exception('Oops !'));

// Capture an exception with additional debug data
$app['raven']->captureException(new \Exception('Oops !'),
    array(
        'extra' => array(
            'php_version' => phpversion()
        ),
    )
);

Obviously you can also provide custom request context :, (*6)

// Bind the logged in user
$app['raven']->user_context(array('email' => 'foo@example.com'));

// Tag the request with something interesting
$app['raven']->tags_context(array('interesting' => 'yes'));

// Provide a bit of additional context
$app['raven']->extra_context(array('happiness' => 'very'));


// Clean all previously provided context
$app['raven']->context->clear();

Example

Here is a full example coupled with Silex error handler (see Silex error handlers documentation) :, (*7)

$app = new Silex\Application();
$app->register(
    new \SilexRaven\RavenServiceProvider(),
    ['raven.dsn' => 'http://public:secret@example.com/1']
);

$app->error(function (\Exception $e, $code) use($app, $user) {
    $app['raven']->user_context(array('email' => $user->email));
    $app['raven']->captureException($e)
    $app['raven']->context->clear();

    return new Response("There is an error !");
});

Resources

The Versions

15/04 2014

dev-master

9999999-dev https://github.com/v-six/silex-raven

A Silex Service Provider for Raven

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kévin Bargoin

silex raven sentry error raven-php

15/04 2014

dev-develop

dev-develop https://github.com/v-six/silex-raven

A Silex Service Provider for Raven

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kévin Bargoin

silex raven sentry error raven-php

15/04 2014

0.1.2

0.1.2.0 https://github.com/v-six/silex-raven

A Silex Service Provider for Raven

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kévin Bargoin

silex raven sentry error raven-php

08/04 2014

0.1.1

0.1.1.0

A Silex Service Provider for Raven

  Sources   Download

The Requires

 

The Development Requires

by Kévin Bargoin

08/04 2014

0.1.0

0.1.0.0

A Silex Service Provider for Raven

  Sources   Download

The Requires

 

The Development Requires

by Kévin Bargoin