Make GET request from Silex to external site

824 views Asked by At

I'm trying to make a GET request to an external site from my Silex application. The only guide I can find about GET requests is the 'sub-Request' guide in the Silex documentation: http://silex.sensiolabs.org/doc/cookbook/sub_requests.html

This is ignoring the base URL and looking at my application.

Does Silex have a provider which can make external GET requests? Or do I have to use pure PHP (for example HttpRequest: http://php.net/manual/en/httprequest.send.php)

1

There are 1 answers

2
BlueM On

A subrequest is not what you are looking for (Silex docs: “simulate requests against your application” – emphasis added).

Chances are that you don’t even need a library, as (with the default PHP configuration) you can simply use file_get_contents() – or other file functions – with a remote URL. You will only need a full-fledged library if you have special needs, such as setting custom headers etc.