tinyfilemanager icon indicating copy to clipboard operation
tinyfilemanager copied to clipboard

Use php function getenv for better Docker support

Open ethanpil opened this issue 3 years ago • 0 comments

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...

ethanpil avatar Aug 23 '22 22:08 ethanpil