Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Merge $_ENV into $_SERVER earlier in phprouter file#333

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kick-the-bucket wants to merge1 commit intosymfony-cli:main
base:main
Choose a base branch
Loading
fromkick-the-bucket:merge_env_into_server_earlier

Conversation

@kick-the-bucket
Copy link

Tried running a non-symfony application with the symfony-cli local server and was puzzled why it could not detect that it's running on https. Apparently'https' => 'on' was only set in$_ENV (that's done withrequire $envFile;), but not in$_SERVER, where PHP applications usually look for that parameter.

This was because the$_SERVER = array_merge($_SERVER, $_ENV); line was never executed, because the router exited a few lines before it withreturn false;.

Also fixed a few whitespace and indentation inconsistencies.

@tucksaun
Copy link
Member

PHP documents the presence ofHTTPS within$_SERVER (seehttps://www.php.net/manual/en/reserved.variables.server.php), not$_ENV.
And I believe most of the literature online also references$_SERVER.

So I think we are within spec here, your app should probably be fixed instead.

@tucksaun
Copy link
Member

Also I don't quite understand how your application could even be reached if the router exited before the call toarray_merge 🤔

@kick-the-bucket
Copy link
Author

After thatreturn false; it just continues to myindex.php, not really sure how that works, maybe the router file is set as anauto_prepend_file 🤔

@kick-the-bucket
Copy link
Author

PHP documents the presence ofHTTPS within$_SERVER (seehttps://www.php.net/manual/en/reserved.variables.server.php), not$_ENV.
And I believe most of the literature online also references$_SERVER.

The problem is that the code in the$envFile only sets$_ENV['https'] = 'on', but nothing on the$_SERVER and that is why the merge is needed in the first place

@tucksaun
Copy link
Member

Oh ok sorry I got that the wrong way.

So I believe the change might makes sense, but at the same time this is the location this merge has been present for quite a long time in Symfony so I'm not entirely sure of the consequences this could have...

Another approach would be to change how we generate the env for the PHP CLI server to make sure the right keys are populated for_SERVER, something along those lines:https://github.com/symfony-cli/symfony-cli/compare/main...tucksaun:symfonycli:fix-generate-server-superglobal-cli-server?expand=1

wdyt@fabpot ?

@kick-the-bucket
Copy link
Author

@tucksaun I actually like your version, no point in setting the variables on$_ENV which are supposed to be in$_SERVER anyways 👍

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@kick-the-bucket@tucksaun@tomas-civinity

[8]ページ先頭

©2009-2025 Movatter.jp