src/Middleware.php
public static function tor($proxy = '127.0.0.1:9050', $torControl = '127.0.0.1:9051')
    {
        return function (callable $handler) use ($proxy, $torControl) {
            return function (
                RequestInterface $request,
                array $options
            ) use ($handler, $proxy, $torControl) {
                $options = array_replace_recursive([
                    'proxy' => $proxy,
                    'curl'  => [
                        CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5_HOSTNAME
                    ]
                ], $options);

                if (array_key_exists('tor_new_identity', $options) && $options['tor_new_identity']) {
                    try {
                        self::requireNewTorIdentity($torControl, $options);
                    } catch (GuzzleException $e) {
                        if (@$options['tor_new_identity_exception']) {
                            throw $e;
                        }
                    }
                }

                return $handler($request, $options);
            };
        };
    }
public static function tor($proxy = '127.0.0.1:9050', $torControl = '127.0.0.1:9051')
    {
        return function (callable $handler) use ($proxy, $torControl) {
            return function (
                RequestInterface $request,
                array $options
            ) use ($handler, $proxy, $torControl) {
                $options = array_replace_recursive([
                    'proxy' => $proxy,
                    'curl'  => [
                        CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5_HOSTNAME
                    ]
                ], $options);

                if (array_key_exists('tor_new_identity', $options) && $options['tor_new_identity']) {
                    try {
                        self::requireNewTorIdentity($torControl, $options);
                    } catch (GuzzleException $e) {
                        if (@$options['tor_new_identity_exception']) {
                            throw $e;
                        }
                    }
                }

                return $handler($request, $options);
            };
        };
    }
public static function tor ( $ proxy = '127.0.0.1:9050' , $ torControl = '127.0.0.1:9051' ) { return function ( callable $ handler ) use ( $ proxy , $ torControl ) { return function ( RequestInterface $ request , array $ options ) use ( $ handler , $ proxy , $ torControl ) { $ options = array_replace_recursive ( [ 'proxy' => $ proxy , 'curl' => [ CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5_HOSTNAME ] ] , $ options ) ; if ( array_key_exists ( 'tor_new_identity' , $ options ) && $ options [ 'tor_new_identity' ] ) { try { self :: requireNewTorIdentity ( $ torControl , $ options ) ; } catch ( GuzzleException $ e ) { if ( @ $ options [ 'tor_new_identity_exception' ] ) { throw $ e ; } } } return $ handler ( $ request , $ options ) ; } ; } ; }
This middleware allows to use Tor client as a proxy

@param string $proxy Tor socks5 proxy host:port
@param string $torControl Tor control host:port
@return callable
This middleware allows to use Tor client as a proxy