【问题标题】:Setting up Sentry with PHP使用 PHP 设置哨兵
【发布时间】:2016-06-10 16:34:28
【问题描述】:

我正在尝试使用 PHP 设置 Sentry 的简单测试。我尝试通过下载手动安装它并将latest sentry-php archive 提取到我的项目文件夹中。

我一直在关注PHP Instructions,并设置了一个简单的单页 php 文件,我认为它可以表明哨兵正在工作。我包含了对不存在的文件的引用以生成 PHP 错误。我知道我的 Raven/Autoloader.php 路径是正确的,因为我测试了从该文件顶部回显消息。

我已经设置了一个 Sentry 帐户和项目,并确保我的来自 sentry 客户端密钥页面的 DNS 包含在 $client = new Raven_Client 语句中。

我已在本地和托管测试服务器上尝试过该文件。 Sentry 中不会记录任何错误或消息。转到我的 Sentry 项目的问题页面,它说它正在等待事件。

任何人都可以建议为什么跟随测试页面不起作用?

<html>
 <head>
  <title>PHP Sentry Test</title>
 </head>
 <body>
 <?php 

// Require raven for Sentry error logging
require_once 'vendor/sentry-php-master/lib/Raven/Autoloader.php';
Raven_Autoloader::register();

// Enable Sentry automatic error and exception capturing which is recomended
$client = new Raven_Client('https://[my-DNS-key-is-here]@app.getsentry.com/82094');
$error_handler = new Raven_ErrorHandler($client);
$error_handler->registerExceptionHandler();
$error_handler->registerErrorHandler();
$error_handler->registerShutdownFunction();


// Capture a message
$event_id = $client->getIdent($client->captureMessage('Try to send a message'));

 echo '<p>Sentry test 1</p>'; 

 // Create n error by looking for a file that isn't there 
 $file=fopen("welcome.txt","r");


 ?> 
 </body>
</html>

【问题讨论】:

  • 服务器是否看到任何请求进入(查看哨兵服务器日志)?
  • 在“问题”下,我只能看到哨兵的示例错误,这与我的一页 PHP 文件无关
  • 我们通过 composer 安装 sentry 来完成这项工作。我写的测试页没有任何问题。我认为docs.getsentry.com/hosted/clients/php 的手动安装说明需要更多的工作。例如,您下载的包中包含一个 composer.json,其中包含对 monolog 的要求。我在下载包中看不到独白,所以大概对于手动安装,用户需要自己添加,但说明中没有提到。
  • 其实Monolog对于Raven的工作来说并不是必须的。我现在意识到,如果你想加入独白,这是一个可选的依赖项。所以它一定是别的东西......
  • 很高兴听到您通过 composer 选项让它工作。如果更多人遇到这个问题,我们会睁大眼睛。

标签: php sentry


【解决方案1】:

您是否尝试过运行 $client-&gt;install() 函数,使用它您将注册所有错误处理程序

【讨论】:

    猜你喜欢
    • 2015-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多