sicaboy/laravel-http-proxy

There is no license information available for the latest version (0.2.1) of this package.

A package allows HTTP proxy

0.2.1 2018-09-05 12:21 UTC

This package is auto-updated.

Last update: 2024-05-06 09:13:56 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Installation

composer require sicaboy/laravel-http-proxy

Setup Service

https://github.com/jhao104/proxy_pool

Laravel 5

Setup

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"

Configuration

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

Usage

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();

Testing

Contribute

https://github.com/sicaboy/laravel-http-proxy/pulls