Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:xampphtdocshomeworkpublic.env]. in C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php:133 Stack trace: #0 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php(91): DotenvLoader::findAndRead(Array) #1 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcDotenv.php(123): DotenvLoader->load() #2 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcDotenv.php(80): DotenvDotenv->loadData() #3 C:xampphtdocshomeworkpublicindex.php(8): DotenvDotenv->load() #4 {main} thrown in C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php on line 133
I`ve solved it. Just change the path to .env file.
Thank you for your service!
You have to use getenv() function to get needed .env variable. The .env file must be in the root of your project and use Composer Autoloader( /vendor/autoload.php) for correct work. To tell the truth, I don’t remember what exactly was my problem, but, if you haven`t solved your problem yet, I can help you via TeamViewer.
TeamViewer
I stuck in same issue. can you help me to fix it
I have the same issue and really dont know what is wrong with my code, I belive that might something with the composer… Can someone help me to fix it plz
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . '/../');
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
Collinsboss18, jamesrandall007, maxganiev, gleissonneves, erenustun, and MarisSuss reacted with heart emoji
@deniskulygin how you fixed this issue?? can you please help me as im getting same.
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:wamp64wwwProServices.env]. in C:wamp64wwwProServicesapplicationvendorvlucasphpdotenvsrcLoader.php on line 133
@mishakansal Make sure you have the file at the said path, in your case, [C:wamp64www]
. Next step, rename the file to just .env
and NOT Proservices.env. No text should precede the file extension.
Got this error..pls help me in finding the solution
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read
the environment file at E:reactjwtsrc.env. in E:reactjwtsrcvendorvluca
sphpdotenvsrcLoader.php:107
Stack trace:
#0 E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php(84): DotenvLoader->e
nsureFileIsReadable()
#1 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(114): DotenvLoader->
load()
#2 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(52): DotenvDotenv->l
oadData()
#3 E:reactjwtsrcbootstrap.php(6): DotenvDotenv->load()
#4 E:reactjwtsrcgenerate_jwt.php(2): require(‘E:reactjwtsr…’)
#5 {main}
thrown in E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php on line 107
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read the
environment file at E:reactjwtsrc.env. in E:reactjwtsrcvendorvlucasphp
dotenvsrcLoader.php:107
Stack trace:
#0 E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php(84): DotenvLoader->e
nsureFileIsReadable()
#1 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(114): DotenvLoader->
load()
#2 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(52): DotenvDotenv->l
oadData()
#3 E:reactjwtsrcbootstrap.php(6): DotenvDotenv->load()
#4 E:reactjwtsrcgenerate_jwt.php(2): require(‘E:reactjwtsr…’)
#5 {main}
thrown in E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php on line 107
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . '/../');
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
This worked for me. I previously had config.env and then I renamed it to .env and it worked. Thanks for the help.
After two hours struggling, in my case the problem was the .env
file permission … change it and you could solve it
If its too up
dig it up!
require "../../vendor/autoload.php";
$dotenv = DotenvDotenv::createImmutable(__DIR__ . "./../../../");
$dotenv->load();
print_r($_ENV);
Then it works!
Hi, I have the same problem. When I launched my app (I have deployed it with Heroku), I receive the errors like:
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [/app/app/controller/.env]. in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php:68
2021-06-13T23:38:59.855043+00:00 app[web.1]: Stack trace:
2021-06-13T23:38:59.855197+00:00 app[web.1]: #0 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(222): DotenvStoreFileStore->read()
2021-06-13T23:38:59.855344+00:00 app[web.1]: #1 /app/app/controller/config.php(12): DotenvDotenv->load()
2021-06-13T23:38:59.855479+00:00 app[web.1]: #2 /app/app/controller/Controller.php(10): include(‘…’)
2021-06-13T23:38:59.855585+00:00 app[web.1]: #3 /app/app/router/router2.php(116): Controller::accueil()
2021-06-13T23:38:59.855621+00:00 app[web.1]: #4 {main}
2021-06-13T23:38:59.855794+00:00 app[web.1]: thrown in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php on line 68
Anyone can help me to find what is the main cause here?
If you are using 7.0 or higher, you may user dirname function and adjust the level (second parameter) to go up according to where the .env is stored.
e.g.
$dotenv = DotenvDotenv::createImmutable(dirname(__DIR__, 2));
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . '/../');
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
This worked for me. I previously had config.env and then I renamed it to .env and it worked. Thanks for the help.
In my installation the file was called .env.example, so I removed the .example and the error was gone
Solved with more accuracy in the project directory $dotenv = DotenvDotenv::createImmutable(dirname(DIR, 1));
In my case, I removed the dot before env from this file vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php
private const DEFAULT_NAME = ‘.env’;
If u move your file from the folder where it was created symfony will keep looking for it on this folder, i’ve went on autoload_runtime and changed on $runtime variable where the project is, just worked for me, lets see on the last composer dump what just happens haha
Содержание
- Unable to read any of the environment file(s) #345
- Comments
- Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:wamp64wwwProServices.env]. in C:wamp64wwwProServicesapplicationvendorvlucasphpdotenvsrcLoader.php on line 133
- Footer
- Fatal error: Uncaught exception #6
- Comments
- Footer
- XDebug in VSCode InvalidPathException /app/.env Loader.php #1501
- Comments
Unable to read any of the environment file(s) #345
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:xampphtdocshomeworkpublic.env]. in C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php:133 Stack trace: #0 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php(91): DotenvLoader::findAndRead(Array) #1 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcDotenv.php(123): DotenvLoader->load() #2 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcDotenv.php(80): DotenvDotenv->loadData() #3 C:xampphtdocshomeworkpublicindex.php(8): DotenvDotenv->load() #4
The text was updated successfully, but these errors were encountered:
I`ve solved it. Just change the path to .env file.
Thank you for your service! 🙂
@deniskulygin What path did you change?
You have to use getenv() function to get needed .env variable. The .env file must be in the root of your project and use Composer Autoloader( /vendor/autoload.php) for correct work. To tell the truth, I don’t remember what exactly was my problem, but, if you haven`t solved your problem yet, I can help you via TeamViewer.
@torressam333 try save file as all files not as text.
I stuck in same issue. can you help me to fix it
I have the same issue and really dont know what is wrong with my code, I belive that might something with the composer. Can someone help me to fix it plz
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
If it’s in public, this suffices:
@deniskulygin how you fixed this issue?? can you please help me as im getting same.
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:wamp64wwwProServices.env]. in C:wamp64wwwProServicesapplicationvendorvlucasphpdotenvsrcLoader.php on line 133
@mishakansal Make sure you have the file at the said path, in your case, [C:wamp64www] . Next step, rename the file to just .env and NOT Proservices.env. No text should precede the file extension.
Got this error..pls help me in finding the solution
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read
the environment file at E:reactjwtsrc.env. in E:reactjwtsrcvendorvluca
sphpdotenvsrcLoader.php:107
Stack trace:
#0 E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php(84): DotenvLoader->e
nsureFileIsReadable()
#1 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(114): DotenvLoader->
load()
#2 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(52): DotenvDotenv->l
oadData()
#3 E:reactjwtsrcbootstrap.php(6): DotenvDotenv->load()
#4 E:reactjwtsrcgenerate_jwt.php(2): require(‘E:reactjwtsr. ‘)
#5
thrown in E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php on line 107
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read the
environment file at E:reactjwtsrc.env. in E:reactjwtsrcvendorvlucasphp
dotenvsrcLoader.php:107
Stack trace:
#0 E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php(84): DotenvLoader->e
nsureFileIsReadable()
#1 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(114): DotenvLoader->
load()
#2 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(52): DotenvDotenv->l
oadData()
#3 E:reactjwtsrcbootstrap.php(6): DotenvDotenv->load()
#4 E:reactjwtsrcgenerate_jwt.php(2): require(‘E:reactjwtsr. ‘)
#5
thrown in E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php on line 107
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
If it’s in public, this suffices:
This worked for me. I previously had config.env and then I renamed it to .env and it worked. Thanks for the help.
After two hours struggling, in my case the problem was the .env file permission . change it and you could solve it
If its too up 😉 😀 dig it up!
Hi, I have the same problem. When I launched my app (I have deployed it with Heroku), I receive the errors like:
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [/app/app/controller/.env]. in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php:68
2021-06-13T23:38:59.855043+00:00 app[web.1]: Stack trace:
2021-06-13T23:38:59.855197+00:00 app[web.1]: #0 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(222): DotenvStoreFileStore->read()
2021-06-13T23:38:59.855344+00:00 app[web.1]: #1 /app/app/controller/config.php(12): DotenvDotenv->load()
2021-06-13T23:38:59.855479+00:00 app[web.1]: #2 /app/app/controller/Controller.php(10): include(‘. ‘)
2021-06-13T23:38:59.855585+00:00 app[web.1]: #3 /app/app/router/router2.php(116): Controller::accueil()
2021-06-13T23:38:59.855621+00:00 app[web.1]: #4
2021-06-13T23:38:59.855794+00:00 app[web.1]: thrown in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php on line 68
Anyone can help me to find what is the main cause here?
If you are using 7.0 or higher, you may user dirname function and adjust the level (second parameter) to go up according to where the .env is stored.
$dotenv = DotenvDotenv::createImmutable(dirname(__DIR__, 2));
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . ‘/../’);
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
This worked for me. I previously had config.env and then I renamed it to .env and it worked. Thanks for the help.
In my installation the file was called .env.example, so I removed the .example and the error was gone
Solved with more accuracy in the project directory $dotenv = DotenvDotenv::createImmutable(dirname(DIR, 1));
In my case, I removed the dot before env from this file vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php
private const DEFAULT_NAME = ‘.env’;
If u move your file from the folder where it was created symfony will keep looking for it on this folder, i’ve went on autoload_runtime and changed on $runtime variable where the project is, just worked for me, lets see on the last composer dump what just happens haha
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
Fatal error: Uncaught exception #6
I am having some issues
Fatal error: Uncaught exception ‘DotenvExceptionInvalidPathException’ with message ‘Unable to read the environment file at C:xampphtdocspokesrcKernels/../. env.’ in C:xampphtdocspokevendorvlucasphpdotenvsrcLoader.php:75 Stack trace: #0 C:xampphtdocspokevendorvlucasphpdotenvsrcLoader.php(52): DotenvLoader->ensureFileIsReadable() #1 C:xampphtdocspokevendorvlucasphpdotenvsrcDotenv.php(90): DotenvLoader->load() #2 C:xampphtdocspokevendorvlucasphpdotenvsrcDotenv.php(48): DotenvDotenv->loadData() #3 C:xampphtdocspokesrcKernelsKernel.php(105): DotenvDotenv->load() #4 C:xampphtdocspokesrcKernelsKernel.php(84): NicklasWPkmGoApiKernelsKernel->loadEnvironmentVariables() #5 C:xampphtdocspokesrcKernelsApplicationKernel.php(60): NicklasWPkmGoApiKernelsKernel->initialize() #6 C:xampphtdocspokesrcKernelsKernel.php(40): NicklasWPkmGoApiKernelsApplicationKernel->initialize() #7 C:xampphtdocspokesrcKernelsApplicationKernel.php(46): NicklasWPkmGoApiKernels in C:xampphtdocspokevendorvlucasphpdotenvsrcLoader.php on line 75
The text was updated successfully, but these errors were encountered:
Have you created the environment file?
- Rename the «.env.example» to «.env»
- Set the LOG_FILE_PATH (the full path to the file)
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
XDebug in VSCode InvalidPathException /app/.env Loader.php #1501
v3.0.0-rc.12 on High Sierra
Drupal 8.6.10 via composer
name: barrio
recipe: drupal8
services:
appserver:
webroot: web
xdebug: true
config:
php: .vscode/php.ini
Tell us about the command you were running
running XDebug in VSCode following instructions from:
https://docs.devwithlando.io/guides/lando-with-vscode.html
Added .vscode/launch.json and .vscode/launch.json to project root per instruction
Tested phpinfo.php which sets a breakpoint and can step through with no problems. Seems to work.
Engage Listen for xDebug in VSCode
Tell us about the error you got
attempt to load Drupal page in chrome
Exception has occurred.
DotenvExceptionInvalidPathException: Unable to read the environment file at /app/.env.
Tell us generally about your bug
set permissions to 775 for /vendor folder contents
lando drush cr
command line shows
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read the environment file at /app/.env. in /app/vendor/vlucas/phpdotenv/src/Loader.php:106
Stack trace:
#0 /app/vendor/vlucas/phpdotenv/src/Loader.php(83): DotenvLoader->ensureFileIsReadable()
#1 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(114): DotenvLoader->load()
#2 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(52): DotenvDotenv->loadData()
#3 /app/load.environment.php(16): DotenvDotenv->load()
#4 /app/vendor/composer/autoload_real.php(66): require(‘/app/load.envir. ‘)
#5 /app/vendor/composer/autoload_real.php(56): composerRequirec9a3c6c392922d24607d6591a83631cb(‘d511210698f02d8. ‘, ‘/app/vendor/com. ‘)
#6 /app/vendor/autoload.php(7): ComposerAutoloaderInitc9a3c6c392922d24607d6591a83631cb::getLoader()
#7 /app/vendor/drush/drush/drush.php(52): include_once(‘/app/vendor/aut. ‘)
#8 /app/vendor/drush/drush/drush(4): require(‘/app/vendor/dru. ‘)
#9
thrown in /app/vendor/vlucas/phpdotenv/src/Loader.php on line 106
PHP Stack trace:
PHP 1.
PHP 2. require() /app/vendor/drush/drush/drush:4
PHP 3. include_once() /app/vendor/drush/drush/drush.php:52
PHP 4. ComposerAutoloaderInitc9a3c6c392922d24607d6591a83631cb::getLoader() /app/vendor/autoload.php:7
PHP 5. composerRequirec9a3c6c392922d24607d6591a83631cb($fileIdentifier = uninitialized, $file = uninitialized) /app/vendor/composer/autoload_real.php:56
PHP 6. require() /app/vendor/composer/autoload_real.php:66
PHP 7. DotenvDotenv->load() /app/load.environment.php:16
PHP 8. DotenvDotenv->loadData($overload = uninitialized) /app/vendor/vlucas/phpdotenv/src/Dotenv.php:52
PHP 9. DotenvLoader->load() /app/vendor/vlucas/phpdotenv/src/Dotenv.php:114
PHP 10. DotenvLoader->ensureFileIsReadable() /app/vendor/vlucas/phpdotenv/src/Loader.php:83
disable XDebug in VSCode then Drupal displays:
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read the environment file at /app/.env. in /app/vendor/vlucas/phpdotenv/src/Loader.php on line 106 Call Stack: 0.0183 408432 1.
The text was updated successfully, but these errors were encountered:
Источник
deniskulygin opened this issue 4 years ago · comments
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:xampphtdocshomeworkpublic.env]. in C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php:133 Stack trace: #0 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php(91): DotenvLoader::findAndRead(Array) #1 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcDotenv.php(123): DotenvLoader->load() #2 C:xampphtdocshomeworkvendorvlucasphpdotenvsrcDotenv.php(80): DotenvDotenv->loadData() #3 C:xampphtdocshomeworkpublicindex.php(8): DotenvDotenv->load() #4 {main} thrown in C:xampphtdocshomeworkvendorvlucasphpdotenvsrcLoader.php on line 133
I`ve solved it. Just change the path to .env file.
Thank you for your service!
You have to use getenv() function to get needed .env variable. The .env file must be in the root of your project and use Composer Autoloader( /vendor/autoload.php) for correct work. To tell the truth, I don’t remember what exactly was my problem, but, if you haven`t solved your problem yet, I can help you via TeamViewer.
TeamViewer
I stuck in same issue. can you help me to fix it
I have the same issue and really dont know what is wrong with my code, I belive that might something with the composer… Can someone help me to fix it plz
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . '/../');
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
@deniskulygin how you fixed this issue?? can you please help me as im getting same.
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [C:wamp64wwwProServices.env]. in C:wamp64wwwProServicesapplicationvendorvlucasphpdotenvsrcLoader.php on line 133
@mishakansal Make sure you have the file at the said path, in your case, [C:wamp64www]
. Next step, rename the file to just .env
and NOT Proservices.env. No text should precede the file extension.
Got this error..pls help me in finding the solution
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read
the environment file at E:reactjwtsrc.env. in E:reactjwtsrcvendorvluca
sphpdotenvsrcLoader.php:107
Stack trace:
#0 E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php(84): DotenvLoader->e
nsureFileIsReadable()
#1 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(114): DotenvLoader->
load()
#2 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(52): DotenvDotenv->l
oadData()
#3 E:reactjwtsrcbootstrap.php(6): DotenvDotenv->load()
#4 E:reactjwtsrcgenerate_jwt.php(2): require(‘E:reactjwtsr…’)
#5 {main}
thrown in E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php on line 107
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read the
environment file at E:reactjwtsrc.env. in E:reactjwtsrcvendorvlucasphp
dotenvsrcLoader.php:107
Stack trace:
#0 E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php(84): DotenvLoader->e
nsureFileIsReadable()
#1 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(114): DotenvLoader->
load()
#2 E:reactjwtsrcvendorvlucasphpdotenvsrcDotenv.php(52): DotenvDotenv->l
oadData()
#3 E:reactjwtsrcbootstrap.php(6): DotenvDotenv->load()
#4 E:reactjwtsrcgenerate_jwt.php(2): require(‘E:reactjwtsr…’)
#5 {main}
thrown in E:reactjwtsrcvendorvlucasphpdotenvsrcLoader.php on line 107
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . '/../');
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
This worked for me. I previously had config.env and then I renamed it to .env and it worked. Thanks for the help.
After two hours struggling, in my case the problem was the .env
file permission … change it and you could solve it
If its too up
dig it up!
require "../../vendor/autoload.php";
$dotenv = DotenvDotenv::createImmutable(__DIR__ . "./../../../");
$dotenv->load();
print_r($_ENV);
Then it works!
Hi, I have the same problem. When I launched my app (I have deployed it with Heroku), I receive the errors like:
PHP Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [/app/app/controller/.env]. in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php:68
2021-06-13T23:38:59.855043+00:00 app[web.1]: Stack trace:
2021-06-13T23:38:59.855197+00:00 app[web.1]: #0 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(222): DotenvStoreFileStore->read()
2021-06-13T23:38:59.855344+00:00 app[web.1]: #1 /app/app/controller/config.php(12): DotenvDotenv->load()
2021-06-13T23:38:59.855479+00:00 app[web.1]: #2 /app/app/controller/Controller.php(10): include(‘…’)
2021-06-13T23:38:59.855585+00:00 app[web.1]: #3 /app/app/router/router2.php(116): Controller::accueil()
2021-06-13T23:38:59.855621+00:00 app[web.1]: #4 {main}
2021-06-13T23:38:59.855794+00:00 app[web.1]: thrown in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php on line 68
Anyone can help me to find what is the main cause here?
If you are using 7.0 or higher, you may user dirname function and adjust the level (second parameter) to go up according to where the .env is stored.
e.g.
$dotenv = DotenvDotenv::createImmutable(dirname(__DIR__, 2));
I know this is late but I had the same issue and I simply named the file to «.env» NOT config.env, var.env e.t.c. From there now you just have to specify the path. I have the .env file at the root of my project and am using the Slim framework. As you know how this frameworks work/how directories are structured, people usually have a public sub-folder and an index.php file inside it which serves as the entry point to the application. If this is the case(mostly Laravel, Symfony e.t.c.) then you just need to get the location of .env file correctly e.g.
$dotenv = DotenvDotenv::createImmutable(__DIR__ . '/../');
If it’s in public, this suffices:
$dotenv = DotenvDotenv::createImmutable(__DIR__);
This worked for me. I previously had config.env and then I renamed it to .env and it worked. Thanks for the help.
In my installation the file was called .env.example, so I removed the .example and the error was gone
Solved with more accuracy in the project directory $dotenv = DotenvDotenv::createImmutable(dirname(DIR, 1));
In my case, I removed the dot before env from this file vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php
private const DEFAULT_NAME = ‘.env’;
If u move your file from the folder where it was created symfony will keep looking for it on this folder, i’ve went on autoload_runtime and changed on $runtime variable where the project is, just worked for me, lets see on the last composer dump what just happens haha
169 votes
0 answers
Get the solution ↓↓↓
I am trying to make a GitHub Actions workflow which will run all my unit tests in my project.
Whenever I push to my CI-CD testing branch it will give me an error saying it is not able to read any of the enviroment files at a certain location [/app/tests/../.env.test]. The .env.test is in the root of my project, so maybe that is the problem but i would not know how to fix that.
The workflow:
name: CI/PHPUnit
on:
push:
branches:
- CI-CD
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout setup
uses: actions/[email protected]
- uses: php-actions/[email protected]
with:
php_version: 7.3
php_extensions: bcmath
- name: PHP unit tests with PHPUnit
uses: php-actions/[email protected]
with:
configuration: phpunit.xml
But this will give me the following error:
Run php-actions/[email protected]
with:
configuration: phpunit.xml
memory_limit: 256M
version: latest
php_version: latest
test_suffix: Test.php,.phpt
Fatal error: Uncaught DotenvExceptionInvalidPathException: Unable to read any of the environment file(s) at [/app/tests/../.env.test]. in /app/vendor/vlucas/phpdotenv/src/Store/FileStore.php:68
Stack trace:
#0 /app/vendor/vlucas/phpdotenv/src/Dotenv.php(222): DotenvStoreFileStore->read()
#1 /app/tests/bootstrap.php(14): DotenvDotenv->load()
#2 /app/tests/Unit/UnitTestCase.php(19): require('/app/tests/boot...')
#3 phar:///usr/local/bin/phpunit/phpunit/Framework/TestBuilder.php(76): EllaTestsUnitUnitTestCase->__construct()
#4 phar:///usr/local/bin/phpunit/phpunit/Framework/TestBuilder.php(64): PHPUnitFrameworkTestBuilder->buildTestWithoutData('Ella\Tests\Unit...')
#5 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(680): PHPUnitFrameworkTestBuilder->build(Object(ReflectionClass), 'testCanAddOrder...')
#6 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(193): PHPUnitFrameworkTestSuite->addTestMethod(Object(ReflectionClass), Object(ReflectionMethod))
#7 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(281): PHPUnitFrameworkTestSuite->__construct(Object(ReflectionClass))
#8 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(377): PHPUnitFrameworkTestSuite->addTestSuite(Object(ReflectionClass))
#9 phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php(394): PHPUnitFrameworkTestSuite->addTestFile('/app/tests/Unit...')
#10 phar:///usr/local/bin/phpunit/phpunit/TextUI/TestSuiteMapper.php(56): PHPUnitFrameworkTestSuite->addTestFiles(Array)
#11 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(304): PHPUnitTextUITestSuiteMapper->map(Object(PHPUnitTextUIXmlConfigurationTestSuiteCollection), '')
#12 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(103): PHPUnitTextUICommand->handleArguments(Array)
#13 phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php(93): PHPUnitTextUICommand->run(Array, true)
#14 /usr/local/bin/phpunit(1119): PHPUnitTextUICommand::main()
#15 {main}
This is my configuration file (phpunit.xml):
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="unit">
<directory suffix=".php">tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
If someone knows a fix for this I would be very happy.
2021-10-20
Write your answer
Share solution ↓
Additional Information:
Date the issue was resolved:
2021-10-20
Link To Source
Link To Answer
People are also looking for solutions of the problem: err_ossl_pem_no_start_line
Didn’t find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.