Skip to content
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

[DependencyInjection] Documenting non-empty container parameters #20246

Merged
merged 1 commit into from
Sep 30, 2024
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
19 changes: 19 additions & 0 deletions configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@ a new ``locale`` parameter is added to the ``config/services.yaml`` file).
They are useful when working with :ref:`Compiler Passes </service_container/compiler_passes>`
to declare some temporary parameters that won't be available later in the application.

Configuration parameters are usually validation-free, but you can ensure that
essential parameters for your application's functionality are not empty::

// ContainerBuilder
$container->parameterCannotBeEmpty('app.private_key', 'Did you forget to configure a non-empty value for "app.private_key" parameter?');

If a non-empty parameter is ``null``, an empty string ``''``, or an empty array ``[]``,
Symfony will throw an exception with the custom error message when attempting to
retrieve the value of this parameter.

.. versionadded:: 7.2

Validating non-empty parameters was introduced in Symfony 7.2.

.. note::

Please note that this validation will *only* occur if a non-empty parameter value
is retrieved; otherwise, no exception will be thrown.

.. seealso::

Later in this article you can read how to
Expand Down
Loading