2

I have a symfony application with two controllers. One of the controllers randomly return an element of an array, like this:

$responses = array("foo", "bar", "baz");

return new JsonResponse($responses[array_rand($responses)]);

The other one has a form and if that form is valid and is submitted it should create a new guzzle client and display one of the array elements from the other controller:

...
if ($form->isSubmitted() && $form->isValid()) {
    $client = new Client([
        'base_uri' => 'foo.local',
    ]);
    $response = $client->request('GET', '/bar');

This results in a cURL error 6: Could not resolve host.

I do have nginx up and running and can access both controllers separately via their routes.

I could not find any solutions, hope someone can help me out with some ideas on this.

1
  • have you tried with the protocol? something like 'base_uri' => 'http://foo.local', Commented Oct 11, 2016 at 15:04

1 Answer 1

2

using protocol in the base uri solves the could not resolve host error

'base_uri' => 'http://foo.local' instead of 'base_uri' => 'foo.local' in this case

Thans for the help @Matteo

Sign up to request clarification or add additional context in comments.

1 Comment

you are welcome! Mark the answer as accepted so you can close the question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.