I have recently updated composer and got the oscarotero/env v2.1.0 package. Since then I keep getting this error:
Fatal error: Uncaught Error: Class 'Env' not found in /myproject/config/application.php:6
This is the content of the referenced file, where Env::init()
corresponds to line 6:
<?php
$root_dir = dirname(__DIR__);
$webroot_dir = $root_dir . '/public';
Env::init();
// Use Dotenv to set required environment variables and load .env file in root
$dotenv = new Dotenv\Dotenv($root_dir);
if (file_exists($root_dir . '/.env')) {
$dotenv->load();
try {
$dotenv->required('DATABASE_URL')->notEmpty();
} catch (Exception $e) {
$dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD', 'WP_HOME', 'WP_SITEURL']);
}
}
It seems as if the package were not loaded since the Env Class doesn’t load. Ideas?