briareos / php-airbrake-bundle
这有助于将php-airbrake模块绑定到Symfony2包中,以便与框架轻松使用。
v1.0.3
2015-04-22 16:19 UTC
Requires
- php: >=5.3.1
- dbtlr/php-airbrake: 1.1.2
- symfony/symfony: >=2.6
This package is not auto-updated.
Last update: 2024-09-28 17:38:29 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]
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标准版构建的基本项目中重现它,以便包的开发者可以通过简单地克隆它并遵循一些步骤来重现问题。