[英]Get variable from parameter file in symfony2
如何在symfony2控制器中從參數文件app / config / parameters.yml獲取變量。
parameters:
host_name: www.mydomain.con
您可以這樣做:
$this->container->getParameter('host_name');
看一下這個
$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!
你會得到這樣的
$this->container->getParameter('host_name');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.