-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
Inconsistency in environment variables #972
Comments
Can you show the PHP code that triggers this error please? |
This is a method to generate the correct API URL, where in the production environment it adds HTTPS and in development it adds HTTP.
You can access this link and you will see that in
Running
Running
These commands were run inside the resulting container from Dockerfile |
Does the error still happen when you use Note: |
Here's an example script: <?php
while(frankenphp_handle_request(function() {
$value = $_ENV['stuff'] ?? null;
echo "_ENV: $value\n";
$value = getenv('stuff');
echo "getenv: $value\n";
$value = $_SERVER['stuff'] ?? null;
echo "_SERVER: $value\n";
})) {} And the output:
Note: if I set php.ini's
I can't reproduce your issue. |
I added I'll leave this noted so I can check it next week with a standard project. If I can reproduce the problem, I'll upload the project here on Github along with the PR to add the line |
I just tried running the sample Symfony project, but I'm noticing that the I've also explicitly set Running this script does seem to populate $_ENV`: <?php
// Boot your app
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Dotenv\Dotenv;
while(frankenphp_handle_request(function() {
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');
$value = $_ENV['APP_ENV'] ?? null;
echo "_ENV: $value\n";
$value = getenv('stuff');
echo "getenv: $value\n";
$value = $_SERVER['stuff'] ?? null;
echo "_SERVER: $value\n";
})) {} Edit: |
What happened?
Apparently FrankenPHP is launching two Goroutines, where one has the environment variables and the other does not, generating this error:
When it is executed by the routine that has the environment variables, the log is just this:
And the system works normally.
If you keep refreshing the page (F5), the result is like this:
In other words, it alternates between the application that has all the environment variables and the other that does not.
In my infrastructure there is only one docker container running my application, so the requests always fall into the same container, including the logs reported here are from the same container.
The problem occurs both on my development machine (x86_64) and on my server (aarch64) in Oracle Cloud.
I use Cloudflare, which is responsible for generating the SSL, but it requires that my server also has a valid SSL, which is a reverse proxy using Traefik, which generates the SSL with Let's Encrypt and within the container the SSL is disabled
SERVER_NAME=my-domain:80
. But in the development environment, access is made directly to thelocalhost:8008
container.My configuration is the same as this repository dunglas/symfony-docker, i only disabled Mercure for Caddy.
I'm using Symfony 7
Build Type
Docker (Debian Bookworm)
Worker Mode
Yes
Operating System
GNU/Linux
CPU Architecture
x86_64
PHP configuration
Relevant log output
No response
The text was updated successfully, but these errors were encountered: