[英]Get variable from parameter file in symfony2
How to get a variable in symfony2 controller from parameters file app/config/parameters.yml . 如何在symfony2控制器中从参数文件app / config / parameters.yml获取变量。
parameters:
host_name: www.mydomain.con
您可以这样做:
$this->container->getParameter('host_name');
Check this out 看一下这个
$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! Enkoy!
你会得到这样的
$this->container->getParameter('host_name');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.