-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Env var maps to undefined constant. #26112
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
Conversation
When I try to use a constant as an environment variable, as described in the blog item, I run into the following problem. Env var "SOME_CONST" maps to undefined constant "App\\Util\\SomeClass::SOME_CONST". The proposed solution works for me, however, I'm not sure if this is the best and conform Symfony standards. Blog: https://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for 3.4
@@ -111,11 +111,13 @@ public function getEnv($prefix, $name, \Closure $getEnv) | ||
} | ||
|
||
if ('const' === $prefix) { | ||
$env = \str_replace("\\\\","\\", $env); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed (the blog post has a typo, the \
should not be doubled there, we're going to fix it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've tested here with and without the double \ but we could not get it to work.
The original scripts runs: return constant($name);
While I only could get it to work with: return constante($env);
Will this be fixted to? Or are we doing something wrong?
@dsmink we've just fixed the blog post ... but we'll need to wait a bit until caches are regenerated. Thanks. |
@javiereguiluz @nicolas-grekas Thanks guys! |
Thank you @dsmink. |
This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #26112). Discussion ---------- Env var maps to undefined constant. When I try to use a constant as an environment variable, as described in the blog item, I run into the following problem. Env var "SOME_CONST" maps to undefined constant "App\\Util\\SomeClass::SOME_CONST". The proposed solution works for me, however, I'm not sure if this is the best and conform Symfony standards. Blog: https://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables | Q | A | ------------- | --- | Branch? | master for features / 2.7 up to 4.0 for bug fixes <!-- see below --> | Bug fix? | yes/no | New feature? | yes/no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | yes/no | Deprecations? | yes/no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes/no | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Replace this comment by a description of what your PR is solving. --> Commits ------- bdf9efc Env var maps to undefined constant.
When I try to use a constant as an environment variable, as described in the blog item,
I run into the following problem.
Env var "SOME_CONST" maps to undefined constant "App\Util\SomeClass::SOME_CONST".
The proposed solution works for me, however, I'm not sure if this is the best and conform Symfony standards.
Blog:
https://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables