2016-11-27 67 views
0

最近我一直在嘗試哎呀!圖書館,並試圖讓它工作,但不幸的是,這是我得到的最接近它的工作。使用「哎呀!」時無法找到課程圖書館?

我使用本教程通過作曲家安裝了 https://code.tutsplus.com/tutorials/whoops-php-errors-for-cool-kids--net-32344

PHP:

<?php 
ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); 
error_reporting(E_ALL); 

# index.php 
require(getcwd() . "/vendor/autoload.php"); 

$whoops = new Whoops\Run(); 
$whoops->pushHandler(new Whoops\Handler\PrettyPageHandler()); 

// Set Whoops as the default error and exception handler used by PHP: 
$whoops->register(); 

throw new RuntimeException("Oopsie!"); 
?> 

錯誤:

Fatal error: Uncaught Error: Class 'Whoops\Run' not found in C:\Users\Administrator\Desktop\CMS\app\library\whoops\index.php:9 Stack trace: #0 {main} thrown in C:\Users\Administrator\Desktop\CMS\app\library\whoops\index.php on line 9 

回答

1

我只是跑你的代碼,它運行良好對我來說(它實際上什麼都沒做,但班級加載得很好)。檢查你的composer.json,並確保它有:

{ 
    "name": "root/stack-overflow", 
    "minimum-stability": "stable", 
    "require": { 
     "filp/whoops": "1.*" 
    } 
} 

運行composer update只是爲了確保。最後確保您的index.php位於以vendor作爲子目錄的目錄中。

+0

雖然當我將composer.json更新爲你的並在composer.json所在目錄中運行作曲家更新時,它沒有您的作曲家代碼,但它只是有「{}」,所以引發了錯誤。 「./composer.json」 不包含有效的JSON 分析錯誤在第1行: 「需要」:{「倒裝/哎呦 --------^ 預期之一: 'EOF', '}',',',']' –

+0

好吧,我會用整個文件更新...這應該可以工作,這是當你運行作曲者時得到的要求filp/whoops 1. *(至少require部分)。 – Katie

0

Whoopsnamespace丟失或它不具有Runclass 。檢查autoload.php並確保它加載Whoops和您所使用的WhoopsRunclass

0

嘗試使用在https://code.tutsplus.com/tutorials/whoops-php-errors-for-cool-kids--net-32344提供的示例,您可以看到加載/vendor/autoload.php稍有不同。

錯誤提示Whoops類未正確加載。

<?php 
# index.php 
require __DIR__ . "/vendor/autoload.php"; 

$whoops = new Whoops\Run(); 
$whoops->pushHandler(new Whoops\Handler\PrettyPageHandler()); 

// Set Whoops as the default error and exception handler used by PHP: 
$whoops->register(); 

throw new RuntimeException("Oopsie!"); 
?>` 

好的。檢查你的路徑是否正確,並且/ vendor /是否包含whoops。 樹應該像

-vendor

--Whoops

--autoload.php

-index.php

+0

這輸出相同的錯誤,沒有改變任何東西。 –

+0

好的。檢查你的路徑是否正確,並且/ vendor /是否包含whoops。 我已將評論放在答案中,因爲我無法在此格式化它。 基本上它看起來像它沒有正確加載Whoops。 – hayres