Closed deniskulygin closed 5 years ago
I`ve solved it. Just change the path to .env file.
Thank you for your service! :)
@deniskulygin What path did you change?
Thanks.
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.
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 = \Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
If it's in public, this suffices:
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__);
@deniskulygin how you fixed this issue?? can you please help me as im getting same.
@mishakansal Make sure you have the file at the said path, in your case, [C:\wamp64\www\]
. 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 Dotenv\Exception\InvalidPathException: Unable to read the environment file at E:\react\jwt\src.env. in E:\react\jwt\src\vendor\vluca s\phpdotenv\src\Loader.php:107 Stack trace:
nsureFileIsReadable()
load()
oadData()
thrown in E:\react\jwt\src\vendor\vlucas\phpdotenv\src\Loader.php on line 107
Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file at E:\react\jwt\src.env. in E:\react\jwt\src\vendor\vlucas\php dotenv\src\Loader.php:107 Stack trace:
nsureFileIsReadable()
load()
oadData()
thrown in E:\react\jwt\src\vendor\vlucas\phpdotenv\src\Loader.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 = \Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
If it's in public, this suffices:
$dotenv = \Dotenv\Dotenv::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 ;) :D dig it up!
require "../../vendor/autoload.php";
$dotenv = Dotenv\Dotenv::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 Dotenv\Exception\InvalidPathException: 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): Dotenv\Store\FileStore->read() 2021-06-13T23:38:59.855344+00:00 app[web.1]: #1 /app/app/controller/config.php(12): Dotenv\Dotenv->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 = Dotenv\Dotenv::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 = \Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
If it's in public, this suffices:$dotenv = \Dotenv\Dotenv::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 = Dotenv\Dotenv::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
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 Dotenv\Exception\InvalidPathException: 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): Dotenv\Store\FileStore->read() 2021-06-13T23:38:59.855344+00:00 app[web.1]: #1 /app/app/controller/config.php(12): Dotenv\Dotenv->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?
Hello, did you manage to solve your problem? I have the same problem with Heroku...
Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at [/Applications/XAMPP/xamppfiles/env]. in /Applications/XAMPP/xamppfiles/htdocs/vita/vendor/vlucas/phpdotenv/src/Store/FileStore.php:68 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/vita/vendor/vlucas/phpdotenv/src/Dotenv.php(222): Dotenv\Store\FileStore->read() #1 /Applications/XAMPP/xamppfiles/htdocs/vita/env_setup.php(7): Dotenv\Dotenv->load() #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/vita/vendor/vlucas/phpdotenv/src/Store/FileStore.php on line 68
I have same issue some please help me
Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at [C:\xampp\htdocs\homework\public.env]. in C:\xampp\htdocs\homework\vendor\vlucas\phpdotenv\src\Loader.php:133 Stack trace: #0 C:\xampp\htdocs\homework\vendor\vlucas\phpdotenv\src\Loader.php(91): Dotenv\Loader::findAndRead(Array) #1 C:\xampp\htdocs\homework\vendor\vlucas\phpdotenv\src\Dotenv.php(123): Dotenv\Loader->load() #2 C:\xampp\htdocs\homework\vendor\vlucas\phpdotenv\src\Dotenv.php(80): Dotenv\Dotenv->loadData() #3 C:\xampp\htdocs\homework\public\index.php(8): Dotenv\Dotenv->load() #4 {main} thrown in C:\xampp\htdocs\homework\vendor\vlucas\phpdotenv\src\Loader.php on line 133