2017 © Pedro Peláez
 

library raven

Raven client for Sentry that supports background processing through multiple providers.

image

rcrowe/raven

Raven client for Sentry that supports background processing through multiple providers.

  • Monday, June 23, 2014
  • by rcrowe
  • Repository
  • 5 Watchers
  • 36 Stars
  • 63,718 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 15 Forks
  • 9 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

Raven

Build Status Latest Stable Version Coverage Status Total Downloads, (*1)

Raven is a client for recording and transmitting messages to Sentry., (*2)

Its special sauce is that it can transmit those messages to Sentry in the background. No more slow down while a HTTP request is made!, (*3)

Raven offers flexibility in how those messages are captured, processed & sent. But also offers quick seemless intergration into a range of frameworks, such as:, (*4)

Sentry, (*5)

Installation

Add rcrowe\raven as a requirement to composer.json:, (*6)

{
    "require": {
        "rcrowe/raven": "~0.2.0"
    }
}

Update your packages with composer update or install with composer install., (*7)

Then follow the instructions for your provider (if you are using one)., (*8)

Usage

This library exposes the same API for recording your messages as the official raven-php client. It should just be a case of replacing Raven_Client with rcrowe\Raven\Client. For usage of recording messages checkout out raven-php., (*9)

To record a message and transmit it to Sentry straight away (the default):, (*10)

$raven = new \rcrowe\Raven\Client(##DSN##);

$raven->captureMessage('FooBar');

Handlers

Handlers are responsible for taking a new captured message and putting into a background queue. If no handler is registered with the raven client the message is transmitted straight away., (*11)

A handler can be added to the client as follows:, (*12)

$raven = new \rcrowe\Raven\Client(##DSN##);

$raven->setHandler(
    new \rcrowe\Raven\Handler\Sync
);
Sync Handler

(Default) Like raven-php new messages are transmitted straight away., (*13)

Laravel Handler

If using within a Laravel project, makes use of the illuminate\queue API. For improved Laravel intergration checkout the Laravel provider below., (*14)

$raven = new \rcrowe\Raven\Client(##DSN##);

$raven->setHandler(
    new \rcrowe\Raven\Handler\Laravel(
        null,
        App::make('queue')
    );
);

Transports

Transports are responsible for sending the message to the Sentry API. Transports are always the first parameter passed into a handler. If no transport is provided it will default to HTTP., (*15)

$raven->setHandler(
    new \rcrowe\Raven\Handler\Sync(
        new \rcrowe\Raven\Transport\Dummy
    )
);
Dummy

Dummy transport does absolutely nothing. Nothing is transmitted to the API. You may not want to transmit any messages when working in a dev environment., (*16)

HTTP

(Default) Transmit the message over HTTP. To do this we make use of the great HTTP client Guzzle., (*17)

$raven->setHandler(
    new \rcrowe\Raven\Handler\Sync(
        new \rcrowe\Raven\Transport\Guzzle
    )
);

As this is the default transport mechanism there is no need to pass it into the handler. The above call is the same as:, (*18)

$raven->addHandler(
    new \rcrowe\Raven\Handler\Sync
);

Providers

Providers offer painless integration to other libraries / frameworks., (*19)

Laravel

Installation

Add the service provider to app/config/app.php:, (*20)

'rcrowe\Raven\Provider\Laravel\RavenServiceProvider',

Optionally register the facade to your aliases:, (*21)

'Sentry' => 'rcrowe\Raven\Provider\Laravel\Facade\Raven',

Configuration

Raven needs to know your client DSN. First publish the Raven config file with the following command:, (*22)

php artisan config:publish rcrowe/raven

Then edit app/config/packages/rcrowe/raven/config.php, (*23)

You can also set your Raven DSN from app/config/services.php:, (*24)

'raven' => [
    'dsn' => '...'
],

Note: Raven makes use of the Laravel queue, so make sure your app/config/queue.php is set correctly., (*25)

Usage

Now where ever you want to record a message just use the normal Log facade., (*26)

try {
    throw new Exception('This is an example');
} catch (Exception $ex) {
    Log::error($ex);
}

To capture and send all messages you can add the following:, (*27)

App::error(function(Exception $exception, $code)
{
    Log::error($exception);
});

Note: Be aware that Laravel does this out of the box in app/start/global.php, (*28)

Using the alias you can set / remove the user information for all messages:, (*29)

Sentry::setUser([
    'id'   => 1,
    'name' => 'Rob Crowe',
]);

Sentry::removeUser();

Note: Check out the config file for more!, (*30)

The Versions

23/06 2014

dev-master

9999999-dev https://github.com/rcrowe/Raven

Raven client for Sentry that supports background processing through multiple providers.

  Sources   Download

The Requires

 

The Development Requires

laravel async worker background raven sentry

13/06 2014

0.2.0

0.2.0.0 https://github.com/rcrowe/Raven

Raven client for Sentry that supports background processing through multiple providers.

  Sources   Download

The Requires

 

The Development Requires

laravel async worker background raven sentry

31/10 2013

0.0.1

0.0.1.0 https://github.com/rcrowe/Raven

Raven client for Sentry that supports background processing through multiple providers.

  Sources   Download

The Requires

 

The Development Requires

async worker background raven sentry