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"
基础教程推荐
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01