bedrock: oscarotero/env v2.1.0 Class 'Env' not found
- I’ve read the guidelines for Contributing to Roots Projects
- This request isn’t a duplicate of an existing issue
- I’ve read the docs and followed them (if applicable)
- This is not a personal support request that should be posted on the Roots Discourse community
Description
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
Steps to reproduce
- Update composer to v2.1.0 on package oscarotero/env
- Check your local repository
Expected behavior: [What you expect to happen]
Expected to run site normally.
Actual behavior: [What actually happens]
Throws error Fatal error: Uncaught Error: Class 'Env' not found in /myproject/config/application.php:6
Reproduces how often: [What percentage of the time does it reproduce?]
100%
Versions
oscarotero/env v2.1.0
Additional information
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?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (4 by maintainers)
composer require vlucas/phpdotenv:^5.2 oscarotero/env:^2.1application.phpto reflect https://github.com/roots/bedrock/blob/master/config/application.php#L31@TangRufus Sure, I’ll try to get a PR ready over the coming weekend.
Download https://patch-diff.githubusercontent.com/raw/roots/bedrock/pull/530.diff and
$ git applyit. However, depends on how much change you made and how “out of sync” your code is, it might not work. For a small patch like #530, manually copy and paste the changes might be easier.Props to @austinpray