realestateconz / php-airbrake-bundle
这有助于将 php-airbrake 模块绑定到 Symfony2 包中,以便于框架使用。
Requires
- php: >=5.3.1
- dbtlr/php-airbrake: ^1.1
This package is not auto-updated.
Last update: 2023-11-21 01:39:46 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 集成。如果你想在 Symfony2 中使用 PHPResque,建议使用来自 hlegius 的 PHPResqueuBundle,因为它使得与 Symfony2 的工进程交互变得简单。
安装并运行后,只需填写 queue 配置变量为你想要使用的队列名称。我建议保持简单,比如使用 'airbrake'。假设你为该队列运行了工作进程,你应该一切顺利。
许可证
此包采用 MIT 许可证。请参阅包中的完整许可证。
Resources/meta/LICENSE
关于
还可以参考 贡献者 列表。
报告问题或功能请求
问题和功能请求在Github问题跟踪器中跟踪。
在报告一个bug时,将其在基于Symfony标准版构建的基本项目中重现可能是个好主意,以便让bundle的开发者通过简单地克隆并遵循一些步骤来重现问题。