PHPackages                             megahertz/guzzle-tor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. megahertz/guzzle-tor

ActiveLibrary[HTTP &amp; Networking](/categories/http)

megahertz/guzzle-tor
====================

This Guzzle middleware allows to use Tor client as a proxy

v1.1.0(5y ago)7069.7k↑13.7%11[1 PRs](https://github.com/megahertz/guzzle-tor/pulls)1MITPHPCI failing

Since Nov 28Pushed 4y ago5 watchersCompare

[ Source](https://github.com/megahertz/guzzle-tor)[ Packagist](https://packagist.org/packages/megahertz/guzzle-tor)[ Docs](http://github.com/megahertz/guzzle-tor)[ RSS](/packages/megahertz-guzzle-tor/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (2)Versions (4)Used By (1)

GuzzleTor
=========

[](#guzzletor)

[![Build Status](https://camo.githubusercontent.com/94c18702948338a7dd1567bdd4477642d14dfa99435a30e9297deca455abe7ed/68747470733a2f2f7472617669732d63692e6f72672f6d656761686572747a2f67757a7a6c652d746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/megahertz/guzzle-tor)

This [Guzzle](https://github.com/guzzle/guzzle) middleware allows to use Tor client as a proxy

```
function get_tor_ip()
{
    $stack = new HandlerStack();
    $stack->setHandler(new CurlHandler());
    $stack->push(Middleware::tor());
    $client = new Client(['handler' => $stack]);

    $response = $client->get('https://check.torproject.org/');

    if (preg_match('/([\d.]+)/', $response->getBody(), $matches)) {
        return $matches[1];
    } else {
        return null;
    }
}
```

Get started
-----------

[](#get-started)

1. Install composer

Follow the instruction at

2. Install guzzle-tor

```
php composer.phar require megahertz/guzzle-tor
```

3. (optional) Copy an example and run

```
cp vendor/megahertz/guzzle-tor/example.php example.php
php example.php
```

Symfony 3/4 config DI
---------------------

[](#symfony-34-config-di)

```
services:

    GuzzleHttp\HandlerStack: ~

    app.client.tor:
      class: GuzzleTor\Middleware
      factory: ['GuzzleTor\Middleware', tor]

    app.client.handler_stack:
      factory: GuzzleHttp\HandlerStack:create
      class: GuzzleHttp\HandlerStack
      calls:
      - [ push, ['@app.client.tor'] ]

    app.client:
      class: GuzzleHttp\Client
      arguments:
      - {handler: '@app.client.handler_stack'}

    #Aliases
    GuzzleHttp\Client: '@app.client'
```

Options
-------

[](#options)

### General

[](#general)

```
Middleware::tor($proxy, $torControl)
```

- **$proxy** is tor socks5 port, by default '127.0.0.1:9050'
- **$torControl** is Tor control port, by default '127.0.0.1:9051'. Set if you want to change ip (clean circuits)

### Request options

[](#request-options)

```
$client->get('https://check.torproject.org/', [
    'tor_new_identity'           => true,
    'tor_new_identity_sleep'     => 15,
    'tor_new_identity_timeout'   => 3,
    'tor_new_identity_exception' => true,
    'tor_control_password'       => 'password'
]);
```

NameDescriptiontor\_new\_identityChange an identity/IP (clean circuits) before request. If it's set, we send NEWNYM signal to Tor client. Please be aware, that this method does not guarantee that an identity will be changed soontor\_new\_identity\_sleepPause (seconds) between an ip change identity and a request sendingtor\_new\_identity\_timeoutTimeout for a Tor control connectiontor\_control\_passwordTor control passwordtor\_new\_identity\_exceptionIf true throw TorNewIdentityException if an error was occurred while trying to change an identity

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 86.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~926 days

Total

3

Last Release

2017d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1762672?v=4)[Alex Prokhorov](/maintainers/megahertz)[@megahertz](https://github.com/megahertz)

---

Top Contributors

[![megahertz](https://avatars.githubusercontent.com/u/1762672?v=4)](https://github.com/megahertz "megahertz (33 commits)")[![dmitry-kulikov](https://avatars.githubusercontent.com/u/3766212?v=4)](https://github.com/dmitry-kulikov "dmitry-kulikov (3 commits)")[![cbastienbaron](https://avatars.githubusercontent.com/u/1092759?v=4)](https://github.com/cbastienbaron "cbastienbaron (1 commits)")[![ChoOo7](https://avatars.githubusercontent.com/u/4919397?v=4)](https://github.com/ChoOo7 "ChoOo7 (1 commits)")

---

Tags

Guzzletoronion

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/megahertz-guzzle-tor/health.svg)

```
[![Health](https://phpackages.com/badges/megahertz-guzzle-tor/health.svg)](https://phpackages.com/packages/megahertz-guzzle-tor)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[guzzlehttp/oauth-subscriber

Guzzle OAuth 1.0 subscriber

24215.4M152](/packages/guzzlehttp-oauth-subscriber)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[eightpoints/guzzle-bundle

Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony. Comes with easy and powerful configuration options and optional plugins.

44512.5M57](/packages/eightpoints-guzzle-bundle)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
