Skip to content

[Runtime] Possibility to define the env and/or debug key #41608

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

Merged
merged 1 commit into from
Sep 27, 2021

Conversation

maxhelias
Copy link
Contributor

@maxhelias maxhelias commented Jun 8, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

As the Dotenv class allows to choose the envKey and the debugKey, it could be interesting to be able to modify it also via the Runtime component.

Example :

$_SERVER['APP_RUNTIME_OPTIONS'] = [
    'env_var_names' => [
        'env_key' => 'ENV_MODE',
        'debug_key' => 'DEBUG_MODE',
    ],
];

@maxhelias maxhelias force-pushed the env-debug-key branch 2 times, most recently from 3b37a6d to 6b3bb0c Compare June 8, 2021 09:27
@nicolas-grekas nicolas-grekas added this to the 5.4 milestone Jun 8, 2021
@nicolas-grekas
Copy link
Member

Do you have a use case? If yes can you explain it? If not, better leave this as is IMHO.

@maxhelias
Copy link
Contributor Author

On many of our projects, clients want to redefine the names of variables or prefix them with the name of their application.
It's always possible to create a custom runtime to work around this, but that requires a lot of override and I'm afraid that we lose the interest of the component.

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.

Thanks for the details.

@javiereguiluz
Copy link
Member

This feature looks reasonable 👍 but I don't like much the names of these options --> "envKey" and "debugKey" To me they sound like some secret key or token related to the environment of the application.

Here's a proposal for your consideration:

// Before
$_SERVER['APP_RUNTIME_OPTIONS'] = [
    'envKey' => 'ENV_MODE',
    'debugKey' => 'DEBUG_MODE',
];

// After
$_SERVER['APP_RUNTIME_OPTIONS'] = [
    'envVarNames' => [
        'env' => 'ENV_MODE',
        'debug' => 'DEBUG_MODE',
    ],
];

@maxhelias
Copy link
Contributor Author

@nicolas-grekas @javiereguiluz what do I do? Which modification do I apply?

@rosier
Copy link
Contributor

rosier commented Jun 16, 2021

My suggestion is mainly about using snake_case consistent. How about combining that with the proposal of @javiereguiluz into:

$_SERVER['APP_RUNTIME_OPTIONS'] = [
    'env_var_names' => [
        'env' => 'ENV_MODE',
        'debug' => 'DEBUG_MODE',
    ],
];

@maxhelias
Copy link
Contributor Author

Status: Needs Review

@fabpot
Copy link
Member

fabpot commented Sep 27, 2021

Thank you @maxhelias.

@maxhelias maxhelias deleted the env-debug-key branch September 27, 2021 12:18
fabpot added a commit that referenced this pull request Sep 27, 2021
This PR was merged into the 5.4 branch.

Discussion
----------

[Runtime] tweak config for env var names

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Tweaking #41608

Commits
-------

c4ef4d7 [Runtime] tweak config for env var names
This was referenced Nov 5, 2021
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.

7 participants