I am trying to make a HTTP Request from one of my controller to contact another URL, the goal being to contact another URL, and to simply print the HTML answer in my page. I tri
I would recommend you using GuzzleHttp Client - best client that I know: http://docs.guzzlephp.org/en/latest/
There is already nice bundle that integrates it into Symfony2 project: https://github.com/8p/GuzzleBundle
Then from your controller you can call:
$client = $this->get('guzzle.client');
// GET request with parameters
$response = $client->get('http://httpbin.org/get', [
'headers' => ['X-Foo-Header' => 'value'],
'query' => ['foo' => 'bar']
]);
$code = $response->getStatusCode();
$body = $response->getBody();
More info can be found on: http://docs.guzzlephp.org/en/latest/index.html