PHP code example of v-six / silex-raven

1. Go to this page and download the library: Download v-six/silex-raven library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

v-six / silex-raven example snippets


$app->register(new SilexRaven\RavenServiceProvider(),
    array(
        'raven.dsn' => 'http://public:[email protected]/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
        )
    )
);

// 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()
        ),
    )
);

// Bind the logged in user
$app['raven']->user_context(array('email' => '[email protected]'));

// 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();

$app = new Silex\Application();
$app->register(
    new \SilexRaven\RavenServiceProvider(),
    ['raven.dsn' => 'http://public:[email protected]/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 !");
});