PHP致命错误:找不到类“ Dotenv” [英] PHP Fatal error: Class 'Dotenv' not found in
问题描述
我有一个项目试图运行它,但出现以下错误:
I've a project I try to run it but I am getting a following error:
PHP Fatal error: Class 'Dotenv' not found in `/home/maras/Documents/eCodile/debtorcare/server/bootstrap/app.php on line 5`
在尝试执行 php artisan start
的过程中,我遇到了这个错误,我尝试重新安装所有依赖项,但没有成功。
我刚刚尝试根据我在Internet上发现的其他类似问题来运行一些命令,但它们中的任何一个都起作用。我试过了:
I'm struggling with this error during trying to execute a php artisan start
I tried to reinstall all dependencies but it didn't work.
I've just tried to run some commands based on other similar problems I found in the Internet but any of them worked. I tried ie:
composer require vlucas / phpdotenv --prefer-dist
我有一个文件 .env
。
这是一个放置错误的文件:
This is a file where error is placed:
<?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放在错误的位置?
Is it possible the error is connected with wrong configuration of a database or phpMyAdmin? Or maybe Ive got .env placed in wrong place?
我尝试在开发中运行该项目。
I try to run this project in development.
推荐答案
我猜您在运行命令时更改了cwd。确保可以从项目根目录加载composer.json,.env, vendor / autoload.php。
I guess the cwd was changed while you're running the command. make sure that composer.json, .env, "vendor/autoload.php" can be loaded from the project root.
也许您需要运行 composer dump-autoload在安装Dotenv之后,
maybe you need to run "composer dump-autoload" after the Dotenv installation,
这篇关于PHP致命错误:找不到类“ Dotenv”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!