PHP error – plugin trying to load .env file
-
php-error: Array ( [type] => 2 [message] => file_get_contents(/web/app/plugins/feeds-for-youtube/.env): Failed to open stream: No such file or directory
I’m getting the above error when trying to use the plugin. Adding a blank .env file to the plugin folder solves the issue.
The issue appears to be this line in bootstrap.php which is attempting to load the .env file in the root.
//Load .env variables
if (class_exists('Dotenv\Dotenv') && method_exists('Dotenv\Dotenv', 'createImmutable')) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
}My recommendation would be to alter this code so it fails more gracefully if there isn’t a .env file available to the plugin, rather than just checking if dotenv exists, e.g:
//Load .env variables
if (class_exists('Dotenv\Dotenv') && method_exists('Dotenv\Dotenv', 'createImmutable')) {
$dotenv_path = __DIR__ . '/.env';
if (file_exists($dotenv_path)) {
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
}
}Thanks in advance
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘PHP error – plugin trying to load .env file’ is closed to new replies.