Guzzle is the de facto library for doing HTTP requests in PHP. There may be cases where you’d prefer not to disclose your IP address when using it. You may also be using 3rd party tools and not be in a great position to introduce the proxying at an application level.
Fortunately, all you need to do is set the
ALL_PROXY environment variable when running your code.
Here’s an example…
// guzzle-test.php <?php require_once('vendor/autoload.php'); $client = new \GuzzleHttp\Client(); $res = $client->request('GET', $argv); echo $res->getBody() . PHP_EOL;
$ ALL_PROXY=socks5://localhost:9050 php guzzle-test.php icanhazip.com 18.104.22.168
Hi, I'm Max!
If you'd like to get in touch with me the best way is on Twitter.