2016-06-10 103 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]