Php Symfony-parameters.yml返回数据
我已经配置了这个参数Php Symfony-parameters.yml返回数据,php,symfony,parameters,Php,Symfony,Parameters,我已经配置了这个参数 w2: wsdl: "some link" sandbox: true api_key: c6480d13-e0a5-4c52-b0a9-dd4e87e9b074 我需要写一条语句,当沙盒为true时返回此数据 $options = [ 'KeyValue' => [ [ 'Key' => 'Sandbox', 'Value' => 't
w2:
wsdl: "some link"
sandbox: true
api_key: c6480d13-e0a5-4c52-b0a9-dd4e87e9b074
我需要写一条语句,当沙盒为true时返回此数据
$options = [
'KeyValue' => [
[
'Key' => 'Sandbox',
'Value' => 'true',
]
],
];
当它是假的时候
$options = [
'KeyValue' => [
[
]
],
];
我不知道如何在我必须编写的函数中包含.yml文件中定义的参数
我试过这个,但我认为那不是解决办法
if ( $this->container->getParameter('w2')['sandbox'] = 1){
$queryOptions = [
'KeyValueOfstringstring' => [
[
'Key' => 'Sandbox',
'Value' => 'true',
]
],
];
}else $queryOptions = [
'KeyValueOfstringstring' => [
[
]
],
];
沙盒参数是否在parameters.yml中?如果是这样,您可以在控制器中以这种方式获取值:
$this->getParameter('sandbox')
。但是您的parameters.yml应该是这样的:
parameters:
sandbox: true
虽然我们通常会在parameters.yml参数中输入,比如:数据库名称、api键、URL
本地和生产环境会有所不同。请记住这一点。和
if(…)
语句应始终至少包含两个=
等号以进行比较,而不仅仅是一个感谢。我的语法正确吗?从这里开始: