Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Simplified the parameters.yml file #722

Closed
wants to merge 3 commits into from
Closed

Simplified the parameters.yml file #722

wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? -
Fixed tickets -
License MIT
Doc PR -

Originally, the parameters.yml was designed to define the infrastructure-related settings (in other words, the settings that may change from one computer to another). Meanwhile, the config_*.yml files are the ones that define the application behavior (in other words, the settings that stay the same from one computer to another).

In my opinion, the three removed parameters are related to application behavior and they shouldn't be defined at the parameters.yml file.

@hacfi
Copy link

hacfi commented Oct 6, 2014

There were added not that long ago and very welcomed by some developers (including myself).

I don’t think it hurts to leave them. Especially debug_toolbar.

@stof
Copy link
Member

stof commented Oct 6, 2014

@hacfi when you use the ParameterHandler to ask you for the parameters when running a composer install (which is quite handy when you add a new feature requiring a new parameter, to avoid having all devs of your team complaining about their setup being broken because of a missing parameter for instance), having parameters which are not related to the infrastructure (and so that you don't need to define yourselves) is annoying.

I would even say that %database_driver% would be a good candidate for the simplification too. Your database platform is very unlikely to change depending on the place where you deploy, as it would make things much harder.
IIRC, the reason it is there was because of the web configurator shipped in SensioDistributionBundle, which was the main way to start using Symfony in the 2.0 era, allowing to configure parameters through a form rather than writing YAML (and failing half of the time because of app/config/parameters.yml not being writable by the webserver...)

@stof
Copy link
Member

stof commented Oct 6, 2014

@hacfi note that nothing prevents you to keep these parameters in your own project if you find them handy

@hacfi
Copy link

hacfi commented Oct 6, 2014

Ok..I’m fine with the removal then. I just thought it’s a feature (enable/disable debug_toolbar) even beginners might want to use early on.

@@ -42,7 +42,7 @@ monolog:
# level: info

assetic:
use_controller: "%use_assetic_controller%"
use_controller: "%kernel.debug%"
Copy link
Member

Choose a reason for hiding this comment

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

given that this setting impacts the routing definitions and the asset url, it would be better to avoid depending on the debug mode but only on the environment. The cached router is not varying based on the debug flag, so accessing the same environment in debug mode and in non-debug mode could create weird issues if the assetic config is based on it.

It is better to define either true or false in config_dev.yaml rather than %kernel.debug%

@lyrixx
Copy link
Member

lyrixx commented Oct 6, 2014

In few projects I maintained, I do the following tricks:

  • I create a app/config/parameters_static.yml will all default values, like email_from, support_email_to, use_real_payment_gateway, assets_on_cdn, toolbar, etc etc.
  • I try to keep app/config/parameters.yml.dist as small as possible (as explained by @javiereguiluz in the PR description).
  • In app/config/config.yml I do
imports:
    - { resource: parameters_static.yml }
    - { resource: parameters.yml }

Like that:

  • all parameters are override-able in parameter.yml
  • specific parameter are override-able in config_test.yml
  • the project installation for new comers is simple
  • it's easy to override some param with ParameterHandler for production deployment

@hacfi
Copy link

hacfi commented Oct 6, 2014

That's a great solution..thanks @lyrixx

@@ -23,3 +23,6 @@ monolog:
level: debug
console:
type: console

assetic:
use_controller: false
Copy link
Member

Choose a reason for hiding this comment

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

this can be avoided as it is already the default

@javiereguiluz
Copy link
Member Author

Now that the "Best Practices" book has been published, another reason for merging this proposal is that it's better aligned with those recommendations.

@hacfi
Copy link

hacfi commented Oct 21, 2014

👍

1 similar comment
@stof
Copy link
Member

stof commented Oct 21, 2014

👍

@fabpot
Copy link
Member

fabpot commented Oct 21, 2014

Thank you @javiereguiluz.

@fabpot fabpot closed this in 87539d1 Oct 21, 2014
@stof
Copy link
Member

stof commented Oct 21, 2014

@fabpot what do you think about my comment related to the database driver ?

@Tobion
Copy link
Contributor

Tobion commented Oct 21, 2014

The locale shouldn't be in parameters as well?! The default locale does not change from server to server or developer to developer.

@Tobion
Copy link
Contributor

Tobion commented Oct 21, 2014

And the changes reverted here were done in #603 exactly to be able to change it per dev.

@Tobion
Copy link
Contributor

Tobion commented Oct 21, 2014

And what about secret. I don't think it's used for CSRF tokens anymore as explained in http://symfony.com/doc/current/reference/configuration/framework.html#secret
And even if yes, it makes no sense that the secret would be different from server to server. If you have a loader balancer in front, the token could be invalid depending on which secret is configured on which server.

@lyrixx
Copy link
Member

lyrixx commented Oct 22, 2014

@Tobion I agree with you about the locale, but I disagree with you for the secret. Because you should avoid to commit "password / secret" in your SCM.

@perajovic
Copy link

Also, when you analyze your app with Insight tool, it suggests you to put your secret key in parameters.yml.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants