Skip to content

Simplify configuration env var example #16575

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 4 commits into from
Closed

Conversation

94noni
Copy link
Contributor

@94noni 94noni commented Mar 7, 2022

Simplify here as the resolve is not needed, as reference it is documented in the dedicated doc page here
https://symfony.com/doc/current/configuration/env_var_processors.html

@carsonbot carsonbot added this to the 4.4 milestone Mar 7, 2022
@94noni 94noni changed the title Update configuration.rst Simplify configuration env var example Mar 7, 2022
@javiereguiluz
Copy link
Member

The resolve env var processor is used in the Symfony recipe (see https://github.com/symfony/recipes/blob/9a7f5bcebbda2f5244c4be4133a6bd181080cbea/doctrine/doctrine-bundle/2.4/config/packages/doctrine.yaml#L1-L3) so this reflects what the reader will see in their config file. Wouldn't it be better to keep it?

@94noni
Copy link
Contributor Author

94noni commented Mar 8, 2022

@javiereguiluz or the other way, what about removing on the recipe? it adds no value here except thinking it is required for env to be "resolved"
for me, the resolved as documented on the env var processor is enough :)

@javiereguiluz
Copy link
Member

Yes, we can ask in the recipe server about this and see if there's a strong reason behind this. Thanks.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Mar 8, 2022

This processor is needed when using a DSN for sqlite.

@94noni
Copy link
Contributor Author

94noni commented Mar 11, 2022

@nicolas-grekas thx for the answer
what about then for a simpler example remove this doctrine config and replace with another?

having the resolve here as first introduction of env var can mislead to using always the resolve as it is mandatory

@javiereguiluz
Copy link
Member

@94noni I agree on your last proposal: let's find a simpler example that doesn't require to use resolve. Do you have something in mind? Thanks!

@94noni
Copy link
Contributor Author

94noni commented Apr 6, 2022

@javiereguiluz Hum what about the famous APP_SECRET ?

just a swap like:

framework:
    secret: '%env(APP_SECRET)%'

xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very unsure of those, may need careful review :s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 509 should be kept :)
Line 507 should be changed to:
xmlns:framework="http://symfony.com/schema/dic/symfony
Finally line 510 and 511 should be changed to refer to:
http://symfony.com/schema/dic/symfony and
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd

@94noni 94noni force-pushed the patch-9 branch 2 times, most recently from a2bc20f to 29e8c20 Compare April 22, 2022 14:06
Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this move, thanks!

xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 509 should be kept :)
Line 507 should be changed to:
xmlns:framework="http://symfony.com/schema/dic/symfony
Finally line 510 and 511 should be changed to refer to:
http://symfony.com/schema/dic/symfony and
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd

@94noni
Copy link
Contributor Author

94noni commented Nov 9, 2022

@HeahDude thx for the review, I just saw them
I hope I've understood this well

@94noni
Copy link
Contributor Author

94noni commented Nov 9, 2022

status: needs review

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there :). Thanks!

https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to keep all the lines here just replacing doctrine/doctrine part by symfony/symfony:

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:framework="http://symfony.com/schema/dic/symfony"
    xsi:schemaLocation="http://symfony.com/schema/dic/services
        https://symfony.com/schema/dic/services/services-1.0.xsd
        http://symfony.com/schema/dic/symfony/symfony
        https://symfony.com/schema/dic/symfony/symfony-1.0.xsd
">

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xmlns:framework="http://symfony.com/schema/dic/symfony
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
xmlns:framework="http://symfony.com/schema/dic/symfony
xmlns:framework="http://symfony.com/schema/dic/symfony"

// by convention the env var names are always uppercase
'url' => '%env(resolve:DATABASE_URL)%',
'secret' => '%env(APP_SECRET)%',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one extra level here (framework.secret.secret), this should be like:

$container->extension('framework', [
    'secret' => '%env(APP_SECRET)%',
]);

@nicolas-grekas
Copy link
Member

Friendly ping @94noni

@94noni
Copy link
Contributor Author

94noni commented Jan 17, 2023

thx for ping, will try to handle it in Feb as I will have some "free time"
edit: as v4.4 is eol, I will close and reopen targeting v5.4, ETA in feb :)

@94noni 94noni closed this Jan 24, 2023
javiereguiluz added a commit that referenced this pull request Feb 8, 2023
This PR was merged into the 5.4 branch.

Discussion
----------

[Config] Simplify configuration env var example

Hi,

This PR supersede [this one](#16575)

```
Simplify here as the `resolve` is not needed, as reference it is documented in the dedicated doc page here
https://symfony.com/doc/current/configuration/env_var_processors.html
```

[Targeting](#16575 (comment)) v5.4 instead of v4.4

friendly ping `@GromNaN` `@javiereguiluz` `@HeahDude` `@nicolas`-grekas as original reviewers

Commits
-------

b15ca74 Simplify configuration env var example
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.

6 participants