akim-bow / guzzle-proxy-handler
Middleware for GuzzleHTTP, allowing easy use of multiple proxy configs
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/akim-bow/guzzle-proxy-handler
Requires
- guzzlehttp/guzzle: ^7.0
- nesbot/carbon: ^2.54
Requires (Dev)
- phpunit/phpunit: ^9.5
README
This library was created to simplify working with proxy through guzzle-http library
composer require akim-bow/guzzle-proxy-handler
Examples
Example 1
// You can use this function to load proxies from config or create proxy array manually $proxyObjects = \ProxyHandler\ProxyManager::getProxyObjects('path to config'); $sps = new SequenceProxyStrategy($proxyObjects); $client = \ProxyHandler\ProxyManager::createProxyClient($sps, [ 'timeout' => 5, ]); $client->get('https://google.com'); $client->get('https://google.com'); $client->get('https://google.com'); echo "Every request was send with configured proxy";
Strategies
Sequence Strategy
This default strategy loops through your proxies and use them consequently.
Weight Strategy
This strategy can be used with a weight class for calculating weight for your request. Cannot be used in async requests.