# Configure TrueProxies with PHP

> Configure TrueProxies with PHP cURL and Guzzle, using HTTP or SOCKS5 authentication, Residential IPv4 country targeting and sticky sessions.

Source: https://docs.trueproxies.com/integrations/php/

> **Use your own endpoints**
>
> The examples below use placeholders. Copy the connection host, ports, username, and proxy password from the **Username and password** tab of your service in the dashboard. See [How to connect](https://docs.trueproxies.com/proxy-instructions/how-to-connect/#connection-host-and-ports).

## cURL

**HTTP**

```php
<?php
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "http://YOUR_HOST:YOUR_HTTP_PORT");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "your_username:your_password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

**SOCKS5**

```php
<?php
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "socks5h://YOUR_HOST:YOUR_SOCKS_PORT");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "your_username:your_password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Guzzle

```php
<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client([
    'proxy' => 'http://your_username:your_password@YOUR_HOST:YOUR_HTTP_PORT',
]);

$response = $client->get('https://httpbin.org/ip');
echo $response->getBody();
```

## Residential IPv4 country targeting

```php
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "your_username-country-us:your_password");
```

## Residential IPv4 sticky sessions

```php
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "your_username-session-abc123:your_password");
```

## Related guides

- [Connection and username format](https://docs.trueproxies.com/proxy-instructions/how-to-connect/)
- [HTTP CONNECT and SOCKS5](https://docs.trueproxies.com/proxy-instructions/proxy-protocols/)
- [Trusted IPs](https://docs.trueproxies.com/proxy-instructions/trusted-ips/)
- [Troubleshooting checklist](https://docs.trueproxies.com/support/)
