Laravel-EnvEditor icon indicating copy to clipboard operation
Laravel-EnvEditor copied to clipboard

🐞 Bug - Custom `.env` files not loaded/manageable

Open Rikj000 opened this issue 2 years ago • 4 comments

Issue description

Example setup with following .env files:

  • .env with APP_ENV="production"
  • .env.testing with APP_ENV="testing"

When you run with an .env file which differs in name from the default .env file (e.g. .env.testing),
as following:

php artisan serve --ansi --port 8081 --env testing

The default .env file (APP_ENV="production") will still be displayed in the _currentEnv.blade.php view-component.

Expected behavior

The contents of the correct .env file (e.g. .env.testing / APP_ENV="testing") will be visible/manageable,
when running the application with a corresponding custom --env parameter (e.g. --env testing).

Rikj000 avatar Apr 19 '23 09:04 Rikj000

This change could solve the issue you describe, but I am not sure if it counts as breaking or not

// Helpers/EnvFilesManager.php:154
    protected function getEnvFileName(): string
    {        
        return app()->environmentFile();
    }

GeoSot avatar Apr 21 '23 20:04 GeoSot

Thank you for the suggestion, it works in my tests!

I'll take this on,
have an idea for a non-breaking / optional implementation.

PR will follow shortly.

Rikj000 avatar Apr 24 '23 12:04 Rikj000

~~Hmmm, I mean draft will follow shortly.. :smile:~~ ~~Seems that reading the correct .env works correctly now,~~
~~but writing fails.. :thinking:~~

Rikj000 avatar Apr 24 '23 12:04 Rikj000

Seems like that was just a caching issue, after clearing caches/restarting it works! :tada: (I can view .env.development + create new setting in it + modify it + delete it)

Rikj000 avatar Apr 24 '23 13:04 Rikj000

Just switched from my forked version to upstream v3.1.0,
and can confirm that the issue has been resolved! :partying_face:

I assume through PR: https://github.com/GeoSot/Laravel-EnvEditor/pull/47

Rikj000 avatar May 23 '24 07:05 Rikj000