https://github.com/softonic/guzzle-proxy-middleware
This package allows you to use a proxy transparently in guzzle.
https://github.com/softonic/guzzle-proxy-middleware
Last synced: about 1 year ago
JSON representation
This package allows you to use a proxy transparently in guzzle.
- Host: GitHub
- URL: https://github.com/softonic/guzzle-proxy-middleware
- Owner: softonic
- License: other
- Created: 2019-01-16T14:20:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T16:54:57.000Z (over 2 years ago)
- Last Synced: 2025-04-10T22:44:19.983Z (about 1 year ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 4
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
Guzzle Proxy Middleware
=====
[](https://github.com/softonic/guzzle-proxy-middleware/releases)
[](LICENSE.md)
[](https://travis-ci.org/softonic/guzzle-proxy-middleware)
[](https://scrutinizer-ci.com/g/softonic/guzzle-proxy-middleware/code-structure)
[](https://scrutinizer-ci.com/g/softonic/guzzle-proxy-middleware)
[](https://packagist.org/packages/softonic/guzzle-proxy-middleware)
[](http://isitmaintained.com/project/softonic/guzzle-proxy-middleware "Average time to resolve an issue")
[](http://isitmaintained.com/project/softonic/guzzle-proxy-middleware "Percentage of issues still open")
This package provides middleware for [guzzle](https://github.com/guzzle/guzzle/) for handling proxy connection using one of the following proxy services:
- [Proxy Bonanza](https://proxybonanza.com)
- [SSL Private Proxy](https://www.sslprivateproxy.com)
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:
```php
$proxyManager = new ProxyManager(
new ProxyBonanza(
new GuzzleClient(),
$cache, // A PSR-6 item pool cache.
'',
''
)
);
```
For SSL Private Proxy:
```php
$proxyManager = new ProxyManager(
new SslPrivateProxy(
new GuzzleClient(),
$cache, // A PSR-6 item pool cache.
''
)
);
```
And inject it to Guzzle with something like:
```php
$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](https://phpunit.de) test suite and a coding style compliance test suite using [PHP CS Fixer](http://cs.sensiolabs.org/).
To run the tests, run the following command from the project folder.
``` bash
$ docker-compose run test
```
To run interactively using [PsySH](http://psysh.org/):
``` bash
$ docker-compose run psysh
```
License
-------
The Apache 2.0 license. Please see [LICENSE](LICENSE) for more information.
[PSR-2]: http://www.php-fig.org/psr/psr-2/
[PSR-4]: http://www.php-fig.org/psr/psr-4/