2016-06-10 104 views
2

我想用PHP设置一个简单的Sentry测试。我试图通过下载手动安装它并将latest sentry-php archive提取到我的项目文件夹中。用PHP设置哨兵

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

我已经设置了一个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> 
+0

是服务器看到进来的任何请求(见哨兵服务器日志)? – ehfeng

+0

在'问题'下,我只能看到来自哨兵的示例错误,这与我的一页PHP文件 –

+0

无关。我们通过使用作曲者来安装哨兵来取得这种效果。我写的测试页没有错。我认为https://docs.getsentry.com/hosted/clients/php/上的手动安装说明需要更多的工作。例如,您下载的软件包包含一个具有monolog要求的composer.json。我无法在下载包中看到monolog,因此大概是手动安装,用户需要自行添加,但在说明中未提及。 –

回答

1

你试过乳宁$client->install()功能,有了它,你将注册所有的错误处理Following pic is from Sentry documentation [1]