softonic / guzzle-proxy-middleware
This package allows you to use a proxy transparently in guzzle.
Installs: 8 550
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 9
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.0
- psr/cache: ^1.0|^2.0|^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
- rector/rector: ^0.11.20
- squizlabs/php_codesniffer: ^3
This package is auto-updated.
Last update: 2024-12-22 19:08:02 UTC
README
This package provides middleware for guzzle for handling proxy connection using one of the following proxy services:
Installation
To install, use composer:
composer require softonic/guzzle-proxy-middleware
Usage
To use this middleware, you need to initialize it like:
For Proxy Bonanza:
$proxyManager = new ProxyManager( new ProxyBonanza( new GuzzleClient(), $cache, // A PSR-6 item pool cache. '<YOUR-USER-PACKAGE-ID>', '<YOUR-API-KEY>' ) );
For SSL Private Proxy:
$proxyManager = new ProxyManager( new SslPrivateProxy( new GuzzleClient(), $cache, // A PSR-6 item pool cache. '<YOUR-API-KEY>' ) );
And inject it to Guzzle with something like:
$stack = new HandlerStack(); $stack->setHandler(new CurlHandler()); $stack->push($proxyManager); $guzzleClient = new GuzzleClient(['handler' => $stack]);
From now on every request sent with $guzzleClient
will be done using a random proxy from your proxy list.
Testing
softonic/guzzle-proxy-middleware
has a PHPUnit test suite and a coding style compliance test suite using PHP CS Fixer.
To run the tests, run the following command from the project folder.
$ docker-compose run test
To run interactively using PsySH:
$ docker-compose run psysh
License
The Apache 2.0 license. Please see LICENSE for more information.