leaf icon indicating copy to clipboard operation
leaf copied to clipboard

_env not working on CLI

Open agarzon-orangerine opened this issue 2 years ago • 1 comments

Describe the bug

The helper function _env() relies on $_ENV validation, preventing the correct use on CLI

To Reproduce Steps to reproduce the behavior:

  1. Run the application using injected environments variables (like in docker and docker-compose and kubernetes) and skip the use of .env file (using .env files in clusters and containers is bad practice)
  2. debug the content of the container (docker) executing the command printenv to verify the variable you want has been injected in the container.
  3. Dump the content using the PHP function getenv() from inside leaf PHP (cli), The variable injected should be there, cool!
  4. Do the same but with _env()... Hmm, the variable is not there!

Expected behavior _env() should read the environment variables just like getenv does.

Additional context I love the simplicity and flexibility of this framework.

What I'm doing is basically running the leaf framework inside a docker container to execute a command (not web), and because is docker, the .env files won't be used to handle environment variables, instead all the variables are injected to the container just like it works with any other framework.

Unfortunately the presence of $_ENV in the validation inside _env function prevent the use of the variable even though the variable was captured by the official PHP function getenv().

agarzon-orangerine avatar Aug 12 '22 16:08 agarzon-orangerine

Hey @agarzon-orangerine, thanks for opening such a detailed issue. I'll confirm the issue and provide a fix for it ASAP.

mychidarko avatar Aug 13 '22 09:08 mychidarko

@agarzon-orangerine An update has been pushed for this.

mychidarko avatar Aug 20 '22 11:08 mychidarko