Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable $_ENV php superglobal #894

Open
rocketeerbkw opened this issue Dec 12, 2023 · 0 comments
Open

Enable $_ENV php superglobal #894

rocketeerbkw opened this issue Dec 12, 2023 · 0 comments

Comments

@rocketeerbkw
Copy link
Member

PHP has a number of superglobals (e.g., $_POST, $_SESSION, etc) which can be enabled/disabled via configuration.

Lagoon ships with the production version of php.ini, which means that the $_ENV superglobal is NOT available. From the php.ini coments:

There is a performance penalty paid for the registration of these arrays and because ENV is not as commonly used as the others, ENV is not recommended on productions servers. You can still get access to the environment variables through getenv() should you need to.

There have been some issues raised because $_ENV["EXAMPLE_SECRET"] isn't working. Since this is very PHP specific, it's commonly assumed that Lagoon isn't passing the variables correctly for some reason. It's not very common, but it does cost time investigating because some users assume that $_ENV is available.

I'm not sure if there is any reason besides the "performance penalty" to keep it disabled? I also can't recall at the moment if $_ENV is typically available in the wider PHP hosting ecosystem? Just grepping the vendor folder of a Drupal project I can see a number of packages that use it.

Options:

  1. Keep the recommended setting. Users should understand how PHP and superglobals work, and getenv() will always work instead of $_ENV.
  2. Enable $_ENV for both fpm and cli images. Assuming that $_ENV is enabled in the wider PHP hosting ecosystem, this puts us in line and provides a better default PHP configuration.
  3. Do nothing, but document it somewhere on docs.lagoon.sh to try and avoid user confusion in the future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant