7

I have an URL defined as a parameter in parameters.yml. I want to create a service which is a SOAP client. The argument of the SOAP client is an URL for a wsdl file. In my case, the URL of the wsdl file is "%parameter_url%" + "?wsdl"`.

Is there a way to concatenate the "?wsdl" to a parameter already defined in YAML?

1
  • Normally, you will have a library to read from config files(yaml). I am not sure about php, but it works for other frameworks/languages. Commented Jun 14, 2015 at 19:26

3 Answers 3

21

You don't need a concatenation character, you can append the constant directly after the parameter. For example, for a service definition in services.yml:

my.service: class: "%my.service.class%" arguments: - "@logger", - "%some_parameter%", - "%parameter_url%?wsdl", 
Sign up to request clarification or add additional context in comments.

1 Comment

Not quoting a scalar starting with the '%' indicator character is deprecated since Symfony 3.1 Just adding quotes around the whole line will work: "%parameter_url%?wsdl"
3

If you are looking to concatenate two parameters. You can do it this way:

parameters.yml

parameter_url: XXXXX parameter_type: ?wsdl

services.yml

my.service: class: %my.service.class% arguments: - @logger, - %some_parameter%, - '%parameter_url%%parameter_type%', 

Comments

0

Following up on redbirdo his response, since not quoting a scalar starting with the '%' indicator character is deprecated since Symfony 3.1:

my.service: class: "%my.service.class%" arguments: - "@logger" - "%some_parameter%" - "%parameter_url%?wsdl" # OR my.service: class: "%my.service.class%" arguments: ["@logger", "%some_parameter%", "%parameter_url%?wsdl"] 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.