2016-05-20 61 views
1

發現我一個項目,我嘗試運行它,但我得到一個以下錯誤:試圖執行期間PHP致命錯誤:類「Dotenv」不

PHP Fatal error: Class 'Dotenv' not found in `/home/maras/Documents/eCodile/debtorcare/server/bootstrap/app.php on line 5` 

我與這個錯誤掙扎a php artisan start我試圖重新安裝所有的依賴關係,但沒有奏效。 我剛剛試圖根據我在互聯網上發現的其他類似問題運行一些命令,但其中任何一個都起作用。我試着即:

composer require vlucas/phpdotenv --prefer-dist

Ive得到了一個文件.env

這是放置錯誤文件:

<?php 

require_once __DIR__.'/../vendor/autoload.php'; 

Dotenv::makeMutable(); 
Dotenv::load(__DIR__.'/../'); 
Dotenv::makeImmutable(); 

/* 
|-------------------------------------------------------------------------- 
| Create The Application 
|-------------------------------------------------------------------------- 
| 
| Here we will load the environment and create the application instance 
| that serves as the central piece of this framework. We'll use this 
| application as an "IoC" container and router for this framework. 
| 
*/ 

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../') 
); 

是否有可能錯誤與數據庫或phpMyAdmin的錯誤的配置連接?或者,也許我已經把.env放在了錯誤的地方?

我嘗試在開發中運行此項目。

回答

1

我猜你在運行命令時改變了cwd。確保可以從項目根目錄加載composer.json,.env,「vendor/autoload.php」。

也許你需要的Dotenv安裝後運行「作曲家自卸自動加載」,

+0

我可以通過什麼方式檢查CWD? –

+0

我之前也嘗試過'composer dump-autoload',但它沒有幫助 –

0

由於c9s建議,檢查以確保您加載現有vendor/autoload.php的東西,如:

$vendor_audoload = __DIR__.'/../vendor/autoload.php'; 
print $vendor_audoload; 
if(file_exists($vendor_audoload)){ 
    print " Exists!"; 
} else { 
    print " Does not exist!"; 
} 
相關問題