Skip to content

Proposed a new "best practice" for parameter naming #7589

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
Mar 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions best_practices/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,31 @@ whereas they cannot access the container parameters:
The only notable disadvantage of using constants for this kind of configuration
values is that you cannot redefine them easily in your tests.

Parameter Naming
----------------

.. best-practice::

The name of your configuration parameters should be as short as possible and
should include a common prefix for the entire application.

Using ``app.`` as the prefix of your parameters is a common practice to avoid
collisions with Symfony and third-party bundles/libraries parameters. Then, use
just one or two words to describe the purpose of the parameter:

.. code-block:: yaml

# app/config/config.yml
parameters:
# don't do this: 'dir' is too generic and it doesn't convey any meaning
app.dir: '...'
# do this: short but easy to understand names
app.contents_dir: '...'
# it's OK to use dots, underscores, dashes or nothing, but always
# be consistent and use the same format for all the parameters
app.dir.contents: '...'
app.contents-dir: '...'

Semantic Configuration: Don't Do It
-----------------------------------

Expand Down