PacketStream integration
Using PacketStream residential proxies with PHP Guzzle
Copy a PHP Guzzle setup for PacketStream's HTTPS or SOCKS5 proxy, then verify the residential exit and add routing modifiers.
If your PHP application already uses Guzzle, configure PacketStream once on the client instead of repeating proxy credentials on every request.
Configure
Install Guzzle and set your PacketStream credentials:
composer require guzzlehttp/guzzle
export PACKETSTREAM_USER='your_username'
export PACKETSTREAM_AUTH_KEY='your_auth_key'
<?php
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
$username = rawurlencode((string) getenv('PACKETSTREAM_USER'));
$authKey = rawurlencode((string) getenv('PACKETSTREAM_AUTH_KEY'));
$proxy = "https://{$username}:{$authKey}@proxy.packetstream.io:31111";
$client = new Client([
'proxy' => $proxy,
'timeout' => 30,
'http_errors' => true,
]);
$response = $client->request('GET', 'https://ipinfo.io');
echo $response->getBody(), PHP_EOL;
With Guzzle’s cURL handler, use socks5h://proxy.packetstream.io:31113 in the proxy URL when the application specifically needs SOCKS5.
Verify your exit
Run the script and inspect the ipinfo.io response for the observed ip and country. Guzzle throws on HTTP errors when http_errors is enabled.
Country targeting and sticky sessions
Append the modifiers before encoding the auth key:
$authKey = rawurlencode(
(string) getenv('PACKETSTREAM_AUTH_KEY') . '_country-US_session-checkout42'
);
$proxy = "https://{$username}:{$authKey}@proxy.packetstream.io:31111";
Keep the modified proxy URL out of logs and exception context.
Troubleshooting
- Confirm the installed cURL library supports an HTTPS proxy. HTTPS destination support is a different capability.
- SOCKS5 proxy URLs require Guzzle’s cURL handler rather than the PHP stream handler.
- Percent-encode both credential components before placing them in the proxy URL.
See proxy troubleshooting for endpoint, TLS, authentication, and timeout checks.