Php 从symfony2中的参数文件获取变量
如何从参数文件app/config/parameters.yml获取symfony2控制器中的变量Php 从symfony2中的参数文件获取变量,php,symfony,Php,Symfony,如何从参数文件app/config/parameters.yml获取symfony2控制器中的变量 parameters: host_name: www.mydomain.con 你可以做: $this->container->getParameter('host_name'); 你会变成这样的 $this->container->getParameter('host_name'); 看看这个 $this->container->getParam
parameters:
host_name: www.mydomain.con
你可以做:
$this->container->getParameter('host_name');
你会变成这样的
$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}}
恩科伊 对于您的用例非常有用