Skip to content

Commit eb3b890

Browse files
committed
documenting non-empty parameters
1 parent 3983e81 commit eb3b890

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

configuration.rst

+15
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,21 @@ a new ``locale`` parameter is added to the ``config/services.yaml`` file).
382382
They are useful when working with :ref:`Compiler Passes </service_container/compiler_passes>`
383383
to declare some temporary parameters that won't be available later in the application.
384384

385+
Configuration parameters are usually constraint-free, but you can ensure that
386+
essential parameters for your application's functionality are present and not
387+
empty::
388+
389+
// ContainerBuilder
390+
$container->nonEmptyParameter('app.private_key', 'Did you forget to configure the "app.private_key" parameter?');
391+
392+
If a non-empty parameter is missing or empty (e.g. ``null``, an empty string ``''``,
393+
or an empty array ``[]``), Symfony will throw an exception with the custom error
394+
message when attempting to retrieve the value of this parameter.
395+
396+
.. versionadded:: 7.2
397+
398+
Defining non-empty parameters was introduced in Symfony 7.2.
399+
385400
.. seealso::
386401

387402
Later in this article you can read how to

0 commit comments

Comments
 (0)