New in Symfony 7.2: Non-Empty Container Parameters
Symfony provides utilities to validate and process configuration parameters
before injecting them as parameters in the application. This is common, for example,
when defining semantic configuration in bundles.
Sometimes, bundles and other packages rely on configuration parameters that might
or might not be defined in the application. Instead of re-validating those parameters
repeatedly across all packages, Symfony 7.2 makes this easier.
Use the new parameterCannotBeEmpty() method on the container to enforce that
a parameter must exist and have a non-empty value:
$container->parameterCannotBeEmpty(
‚app.private_key‘,
‚Did you forget to configure a value for the „app.private_key“ parameter?‘
);
Symfony will check that the app.private_key parameter exists and that its value
is not null, an empty string, or an empty array. If any of these conditions
fail, you’ll see the following error message:
You have requested a non-existent parameter „app.private_key“.
Did you forget to configure a value for the „app.private_key“ parameter?
Symfony Blog