[GH-ISSUE #840] Use php function getenv for better Docker support #567

Open
opened 2026-03-02 15:59:50 +03:00 by kerem · 0 comments
Owner

Originally created by @ethanpil on GitHub (Aug 23, 2022).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/840

I'd love to see better support for Docker environment variables to more easily customize the configuration in a more "Dockery" way. The solution seems easy, to use PHP's getenv() function when setting the defaults in tinyfilemanager.php

For example, on line 23 of tinyfilemanager.php we have:

$use_auth = true;

We can replace this with the following:
$use_auth = getenv("USE_AUTH") ? getenv("USE_AUTH") : true;

This will check for an environment variable USE_AUTH to set the value. If the value doesn't exist, it will default to true and existing functionality wont change even for users that opted to use config.php

We can even add some error checking to make sure poorly formed values will still work

$use_auth = getenv("USE_AUTH") && is_bool( getenv("USE_AUTH") ) ? getenv("USE_AUTH") : true;

Happy to submit a PR to help if you are interested.

Another (simpler) option may be to just use getenv() to define a config file path which can be loaded...

Originally created by @ethanpil on GitHub (Aug 23, 2022). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/840 I'd love to see better support for Docker environment variables to more easily customize the configuration in a more "Dockery" way. The solution seems easy, to use PHP's `getenv()` function when setting the defaults in `tinyfilemanager.php` For example, on [line 23 of tinyfilemanager.php](https://github.com/prasathmani/tinyfilemanager/blob/74727fe48abcb8ccbb8014510f24981c786bd522/tinyfilemanager.php#L23) we have: `$use_auth = true;` We can replace this with the following: `$use_auth = getenv("USE_AUTH") ? getenv("USE_AUTH") : true;` This will check for an environment variable `USE_AUTH` to set the value. If the value doesn't exist, it will default to `true` and existing functionality wont change even for users that opted to use `config.php` We can even add some error checking to make sure poorly formed values will still work `$use_auth = getenv("USE_AUTH") && is_bool( getenv("USE_AUTH") ) ? getenv("USE_AUTH") : true;` Happy to submit a PR to help if you are interested. Another (simpler) option may be to just use `getenv()` to define a config file path which can be loaded...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#567
No description provided.