composer require sicaboy/laravel-http-proxy
https://github.com/jhao104/proxy_pool
NOTE This package supports the auto-discovery feature of Laravel 5.5, So skip these Setup
instructions if you're using Laravel 5.5.
In app/config/app.php
add the following :
1- The ServiceProvider to the providers array :
Sicaboy\LaravelHttpProxy\HttpProxyServiceProvider::class,
2- The class alias to the aliases array :
'HttpProxy' => Sicaboy\LaravelHttpProxy\Facades\HttpProxy::class,
3- Publish the config file
php artisan vendor:publish --provider="Sicaboy\LaravelHttpProxy\HttpProxyServiceProvider"
Add lines in .env file :
HTTP_PROXY_PROTOCOL=http
HTTP_PROXY_HOST=127.0.0.1
HTTP_PROXY_PORT=5010
HTTP_PROXY_CACHE_ENABLED=false
HTTP_PROXY_CACHE_KEY=laravel-http-proxy
HTTP_PROXY_CACHE_TTL=300
use Sicaboy\LaravelHttpProxy\Facades\HttpProxy;
// Get a valid proxy. e.g."12.34.56.78:8080"
$proxy = HttpProxy::getProxy();
// Give up the current cached proxy and get another valid proxy
$proxy = HttpProxy::refreshProxy();