Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use WeProxy with PHP

WeProxy — PHP proxy example

Website PHP Integrations

Route outbound HTTP(S) through WeProxy using PHP cURL — the same stack most PHP scrapers, WordPress jobs, and CLI workers already ship with.


What this demo does

  1. Reads gateway settings from the environment
  2. Configures CURLOPT_PROXY + CURLOPT_PROXYUSERPWD
  3. Requests https://api.ipify.org
  4. Prints the exit IP (or a clear error)

No Composer packages required — only the curl extension.

Requirements

  • PHP 8.0+ with curl enabled (php -m | findstr curl)
  • WeProxy user/password from my.we1.town

Setup

cp .env.example .env

This minimal sample does not auto-load .env. Export variables in your shell:

export WEPROXY_USER="your-user"
export WEPROXY_PASS="your-pass"
# optional overrides:
# export WEPROXY_HOST=gw.weproxy.com.tr
# export WEPROXY_PORT=8989

PowerShell:

$env:WEPROXY_USER="your-user"
$env:WEPROXY_PASS="your-pass"

Run

php src/check-ip.php

Core snippet

<?php
$ch = curl_init('https://api.ipify.org');
curl_setopt($ch, CURLOPT_PROXY, 'gw.weproxy.com.tr:8989');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'USER:PASSWORD');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Production-ready version with timeouts and exit codes: src/check-ip.php.

Useful cURL options for proxies

Option Purpose
CURLOPT_PROXY host:port
CURLOPT_PROXYUSERPWD user:pass
CURLOPT_PROXYTYPE CURLPROXY_HTTP (default here)
CURLOPT_CONNECTTIMEOUT Fail fast on dead gateways
CURLOPT_TIMEOUT Cap total wait

For SOCKS5 packages, switch CURLOPT_PROXYTYPE to the matching CURLPROXY_SOCKS5 constant only if the panel enables SOCKS for your line.

Drop into frameworks

  • Plain PHP / CLI cron — call the script or copy the options into your existing curl_init flow
  • Laravel HTTP client — configure a Guzzle handler stack with proxy URL http://USER:PASS@gw.weproxy.com.tr:8989
  • Guzzle directly — 'proxy' => 'http://USER:PASS@gw.weproxy.com.tr:8989'

Product choice (residential vs datacenter) is entirely in the credentials, not in PHP code. See Pricing and Rotating residential.

Troubleshooting

Issue Fix
curl class missing Install php-curl / enable extension
Empty body + error string Print curl_error($ch); check auth
SSL complaints to target Usually unrelated to proxy; verify CA bundle
Works in browser tools only Confirm CLI uses the same env user/pass

Baseline without PHP:

curl -x http://USER:PASSWORD@gw.weproxy.com.tr:8989 https://api.ipify.org

Project layout

php-proxy/
├── assets/banner.png
├── src/check-ip.php
├── .env.example
└── README.md

Related

License

MIT — see LICENSE.

About

PHP cURL + WeProxy HTTP proxy example (CURLOPT_PROXY, exit IP check)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages