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

Appearance settings

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

Closed
wants to merge 1 commit into from
Closed

Conversation

dsmink
Copy link
Contributor

@dsmink dsmink commented Feb 9, 2018

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
Bug fix? yes/no
New feature? yes/no
BC breaks? yes/no
Deprecations? yes/no
Tests pass? yes/no
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#...

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
Copy link
Member

@nicolas-grekas nicolas-grekas left a 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);
Copy link
Member

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)

Copy link
Contributor Author

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?

@javiereguiluz
Copy link
Member

@dsmink we've just fixed the blog post ... but we'll need to wait a bit until caches are regenerated. Thanks.

@dsmink
Copy link
Contributor Author

dsmink commented Feb 9, 2018

@javiereguiluz @nicolas-grekas Thanks guys!

@nicolas-grekas
Copy link
Member

Thank you @dsmink.

nicolas-grekas added a commit that referenced this pull request Feb 9, 2018
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.
@xabbuh xabbuh added this to the 3.4 milestone Feb 12, 2018
This was referenced Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.