开发者

import Constants in Symfony2 Service Container with a yml file

开发者 https://www.devze.com 2023-03-30 16:51 出处:网络
I would like to import constant in the Symfony2 Service Container. There is a cookbook which explains how to do it: link to cookbook

I would like to import constant in the Symfony2 Service Container. There is a cookbook which explains how to do it: link to cookbook

According to this cookbook, you can't import constant in a yml file. However, it has not been modified for 3 month, and not updated when Symfony2 went live.

Does anybody kno开发者_如何学运维w if it's possible to import constant with a yml file now ?

Thanks in advance


if you use the symfony standard edition, you can add parameters into the app/config/parameters.ini file.

If you really want to use a yaml file, you can do that:

parameters:
    my.parameter: foobar

and then, you will be able to access in a controller like this:

$this->container->getParameter('my.parameter');
0

精彩评论

暂无评论...
验证码 换一张
取 消