I am using yii 2 and
I installed the package:
"vlucas/phpdotenv": "^5.6"
And in the root directory I have a folder env/dev/.env.dev
So I changed the web/index.php file like:
<?php
// phpcs:ignoreFile
//$path = dirname(__DIR__ . '/', './env/dev/.env.dev' );
//require $path . '/vendor/autoload.php';
$dotEnv = DotenvDotenv::createImmutable(__DIR__ . '/', '/env/dev/.env.dev');
$dotEnv->load();
defined('YII_DEBUG') or define('YII_DEBUG', $_ENV['YII_DEBUG']);
defined('YII_ENV') or define('YII_ENV', $_ENV['YII_ENV']);
require $path . '/vendor/yiisoft/yii2/Yii.php';
$config = require $path . '/config/web.php';
try {
(new yiiwebApplication($config))->run();
} catch (yiibaseInvalidConfigException $exception) {
echo $exception->getMessage();
}
But then I get this error:
<br />
<b>Fatal error</b>: Uncaught Error: Class "DotenvDotenv" not found in
C:reposinternet_backendwebindex.php:7
Stack trace:
#0 {main}
thrown in <b>C:reposinternet_backendwebindex.php</b> on line <b>7</b><br />
Question: how to run the .env file?