PHP Fatal error: Class #39;Dotenv#39; not found in(PHP 致命错误:在中找不到类“Dotenv)
问题描述
我有一个项目,我尝试运行它,但出现以下错误:
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 时遇到此错误,我尝试重新安装所有依赖项,但没有成功.我刚刚尝试根据我在互联网上发现的其他类似问题运行一些命令,但其中任何一个都有效.我试过了:
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 需要 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 LaravelLumenApplication(
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.
也许你需要在 Dotenv 安装后运行composer dump-autoload",
maybe you need to run "composer dump-autoload" after the Dotenv installation,
这篇关于PHP 致命错误:在中找不到类“Dotenv"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 致命错误:在中找不到类“Dotenv"
基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
