承接 v-six/silex-raven 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

v-six/silex-raven

Composer 安装命令:

composer require v-six/silex-raven

包简介

A Silex Service Provider for Raven

README 文档

README

A basic Silex service provider for PHP client for Sentry : getsentry/raven-php.

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:

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

Alternatively, you can download the silex-raven.zip file and extract it.

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.

Custom

You can easily capture an error or an exception with the following :

// 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 :

// 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) :

$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

统计信息

  • 总下载量: 7.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固