Skip to content

[DependencyInjection][Improve] Constant YAML with expression language #7395

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

Closed
wants to merge 2 commits into from
Closed
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
17 changes: 17 additions & 0 deletions service_container/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ key and define the type as ``constant``.

.. configuration-block::

.. code-block:: yaml

parameters:
global.constant.value: "@=constant('GLOBAL_CONSTANT')"
my_class.constant.value: "@=constant('My_Class::CONSTANT_NAME')"

.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
Expand All @@ -243,6 +249,12 @@ key and define the type as ``constant``.
$container->setParameter('global.constant.value', GLOBAL_CONSTANT);
$container->setParameter('my_class.constant.value', My_Class::CONSTANT_NAME);

.. caution::

It's also possible to use PHP constants in YAML files using expression language.
You must have :doc:`/components/expression_language` installed.
To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`.

.. tip::

If you're using YAML, you can :doc:`import an XML file </service_container/import>`
Expand All @@ -253,6 +265,11 @@ key and define the type as ``constant``.
imports:
- { resource: parameters.xml }

.. note::

In Symfony 3.2 YAML support PHP constants.


PHP Keywords in XML
-------------------

Expand Down