如何从参数文件 app / config / parameters.yml 获取symfony2控制器中的变量。
parameters:
host_name: www.mydomain.con
答案 0 :(得分:4)
你可以这样做:
$this->container->getParameter('host_name');
答案 1 :(得分:0)
检查出来
$this->container->getParameter('host_name');
And if you want in twig then try like below
Add in app/config/config.yml like:
twig:
globals:
host_name: '%host_name%'
and in twig file use as normal variable like:
{{host_name}}
Enkoy!
答案 2 :(得分:-1)
你会得到这样的
$this->container->getParameter('host_name');