ibrows / php-airbrake-bundle
这有助于将php-airbrake模块绑定到Symfony2框架包中,以便易于使用。
2.0.0
2018-08-23 10:46 UTC
Requires
- php: >=5.3.1
- ibrows/php-airbrake: 1.*
- symfony/config: ~2.0|^3.0
- symfony/dependency-injection: ~2.0|^3.0
- symfony/http-kernel: ~2.0|^3.0
- symfony/swiftmailer-bundle: ~2.0|^3.0
Requires (Dev)
- phpunit/phpunit: ^5.6
This package is auto-updated.
Last update: 2024-09-15 19:51:03 UTC
README
这有助于将 php-airbrake模块 绑定到Symfony2框架包中,以便易于使用。它将在框架中自动加载异常处理器,以便将所有未捕获的错误发送到Airbrake服务。
安装说明
使用deps(适用于Symfony 2.0)
将这些块添加到以下文件中
deps
[PhpAirbrakeBundle]
git=http://github.com/nodrew/PhpAirbrakeBundle.git
target=/bundles/Nodrew/Bundle/PhpAirbrakeBundle
[php-airbrake]
git=http://github.com/nodrew/php-airbrake.git
target=/bundles/Nodrew/Bundle/PhpAirbrakeBundle/vendor/php-airbrake
app/autoload.php
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
...
'Nodrew' => __DIR__.'/../vendor/bundles',
...
));
使用composer(适用于Symfony 2.1)
安装此库的最佳方式是使用Composer。将以下内容添加到项目根目录下的composer.json
{ "require": { "nodrew/php-airbrake-bundle": "dev-master" } }
在Kernel中包含Bundle
app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// System Bundles
...
new Nodrew\Bundle\PhpAirbrakeBundle\PhpAirbrakeBundle(),
...
);
}
配置
app/config/config.yml
php_airbrake:
api_key: %airbrake_api_key%
api_endpoint: [optional custom API endpoint eg. http://api.airbrake.io/notifier_api/v2/notices]
queue: [optional resqueue queue name]
email_to: test@test.ch
disabled: false # %kernel.debug% maybe
app/config/parameters.ini
airbrake_api_key="[airpbrake api key]"
手动调用Airbrake
可以在服务容器中找到Airbrake客户端,可以使用如下方式使用:
<?php $client = $container->get('php_airbrake.client'); $client->notifyAboutError('Something really bad happened!'); $client->notifyAboutException(new Exception('Why did I catch this? It would have been caught on its own!?!'));
Resque集成
此客户端将允许通过提供将错误添加到的Resque队列名称与PHPResque集成。建议如果您想使用PHPResque与Symfony2集成,请使用来自hlegius的PHPResqueuBundle,因为它使与Symfony2的worker进程接口变得非常简单。
一旦安装并运行,只需在queue配置变量中填写您想使用的队列名称。我建议使用类似'airbrake'这样的简单名称。假设您有一个为此队列运行的worker进程,那么您应该没问题。
许可
此包受MIT许可协议保护。请参阅包中的完整许可协议。
Resources/meta/LICENSE
关于
请参阅贡献者列表。
报告问题或功能请求
问题和功能请求在Github问题跟踪器中跟踪。
在报告错误时,最好在Symfony标准版构建的基本项目中重现它,以便让包的开发者通过简单地克隆它并遵循一些步骤来重现问题。