Download the PHP package ecourty/tor-php without Composer
On this page you can find all versions of the php package ecourty/tor-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ecourty/tor-php
More information about ecourty/tor-php
Files in ecourty/tor-php
Package tor-php
Short Description A Symfony-based HTTP client and ControlPort client for interacting with the Tor network in PHP.
License MIT
Informations about the package tor-php
TOR-PHP
TOR-PHP is a PHP library for Tor network integration. It provides two main components:
- TorHttpClient - A Symfony HttpClient implementation that routes HTTP requests through the Tor SOCKS5 proxy for anonymous communication.
- TorControlClient - A socket-based client implementing the Tor Control Protocol for managing circuits, configuration, and onion services.
Table of Contents
- Quick Start
- Installation
- Requirements
- Authentication
- Password Authentication
- Cookie Authentication
- No Authentication
- Features
- HTTP Client Features
- Control Client Features
- Security Baseline
- Usage Examples
- Example 1: HTTP Requests via Tor
- Example 2: Request a New Identity
- Example 3: Manage Your Tor Node
- Example 4: Generate Onion Service Keys
- Changelog
- Contributing
- License
Quick Start
-
Install and start Tor:
-
Install TOR-PHP:
- Make your first request:
Installation
1. Install Tor
On Debian/Ubuntu
On macOS (Homebrew)
2. Configure Tor ControlPort
Edit your Tor configuration file (/etc/tor/torrc or /usr/local/etc/tor/torrc):
See the Authentication section for configuring authentication.
3. Install TOR-PHP via Composer
Requirements
- PHP 8.4 or higher
- Tor daemon running locally
- ControlPort enabled in Tor configuration (required for
TorControlClientfeatures)
Authentication
The Tor ControlPort should always be protected with authentication. TOR-PHP supports three authentication methods.
Password Authentication
Recommended for production environments.
-
Generate a hashed password:
-
Add to
/etc/tor/torrc: - Use in PHP:
Cookie Authentication
Recommended when the PHP process runs as the same user as Tor.
-
Configure
/etc/tor/torrc: -
Use in PHP:
The cookie file path varies by system:
- Linux:
/var/run/tor/control.authcookie - macOS (Homebrew):
/usr/local/var/run/tor/control.authcookie
- Linux:
No Authentication (Not Recommended)
Only use for local development on isolated systems.
Configure /etc/tor/torrc:
Use in PHP:
Warning: Running Tor ControlPort without authentication is a security risk. Any process on the system can control your Tor instance.
Features
HTTP Client Features
- HTTP/HTTPS requests through Tor SOCKS5 proxy (port 9050)
- Request new identity (change Tor circuit)
- Retrieve current Tor exit nodes
- Compatible with Symfony HttpClient interface
Control Client Features
- Circuit management and inspection
- Signal new identity (
NEWNYM) - Configuration management (
GETCONF,SETCONF) - Onion service creation and deletion
- ED25519-V3 keypair generation for onion services
- Tor event subscription
- Wait for circuit build completion
Security Baseline
Mandatory Authentication
Running Tor ControlPort without authentication is dangerous. An attacker with local access could:
- Reconfigure your Tor instance
- Create onion services
- Monitor your traffic
- Manipulate circuits
Always use password or cookie authentication in production.
Best Practices
- Protect credentials: Never commit passwords or cookie files to version control
-
File permissions: Set restrictive permissions on sensitive files:
-
Environment variables: Store credentials in environment variables:
- Sensitive parameter protection: TOR-PHP uses
#[\SensitiveParameter]to prevent credential leakage in stack traces
Usage Examples
Example 1: Get current IP via Tor
Example 2: Request a New Identity
Example 3: Manage Your Tor Node
Example 4: Generate Onion Service Keys
Other code examples can be found here.
Changelog
See CHANGELOG.md for details.
Contributing
See CONTRIBUTING.md for contribution guidelines.
License
Author: Edouard Courty
License: MIT - See LICENSE
Copyright © 2025
Need Help?
Feel free to open an issue or contribute via pull requests.