Symfony2 Use PHP Class Constant in YAML Config?

后端 未结 6 1834
梦如初夏
梦如初夏 2020-12-15 05:45

I know this is probably not possible, but is there a clean way to use a PHP class constant within a YAML config/services/etc. file for Symfony2?

For example, if I ha

6条回答
  •  无人及你
    2020-12-15 06:18

    In versions before Symfony 3.2, injecting PHP-constants only works with XML:

    My\Bundle\DependencyInjection\MyClass::MY_CONST
    

    If you want to keep yor yml files, you could just import the xml-file into your services.yml. Mixing config styles might be a bit ugly, but as far as I know this is the only way to do it.

    If this doesn't work for you, my comment to your question applies.

提交回复
热议问题