Title: PHP error &#8211; plugin trying to load .env file
Last modified: July 10, 2024

---

# PHP error – plugin trying to load .env file

 *  Resolved [letterafterz](https://wordpress.org/support/users/letterafterz/)
 * (@letterafterz)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/php-error-plugin-trying-to-load-env-file/)
 *     ```wp-block-code
       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.
 *     ```wp-block-code
       //Load .env variablesif (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:
 *     ```wp-block-code
       //Load .env variablesif (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)

 *  [Smash Balloon Nigel](https://wordpress.org/support/users/nigelrsb/)
 * (@nigelrsb)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/php-error-plugin-trying-to-load-env-file/#post-17881279)
 * Hi [@letterafterz](https://wordpress.org/support/users/letterafterz/)
 * Thank you for bringing this to our attention. I just wanted to let you know that
   I’m working on this.
 * I am checking with my colleagues to get more details on this. I’ll get back to
   you as soon as I have an update; thank you in advance for your patience. If you
   have any additional thoughts or questions in the meantime, please let me know.

Viewing 1 replies (of 1 total)

The topic ‘PHP error – plugin trying to load .env file’ is closed to new replies.

 * ![](https://ps.w.org/feeds-for-youtube/assets/icon-256x256.png?rev=2700809)
 * [Feeds for YouTube (YouTube video, channel, and gallery plugin)](https://wordpress.org/plugins/feeds-for-youtube/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/feeds-for-youtube/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/feeds-for-youtube/)
 * [Active Topics](https://wordpress.org/support/plugin/feeds-for-youtube/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/feeds-for-youtube/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/feeds-for-youtube/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Smash Balloon Nigel](https://wordpress.org/support/users/nigelrsb/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/php-error-plugin-trying-to-load-env-file/#post-17881279)
 * Status: resolved