PHP TorControl, a library to control TOR
MIT License
TorControl is a PHP library to control a Tor server.
Note: if you use the Symfony framework, you should use DunglasTorControlBundle.
If not already done, install Composer.
Add php-torcontrol to your composer.json
:
composer require dunglas/php-torcontrol
<?php
// Autoloading using composer
require 'vendor/autoload.php';
// Connect to the TOR server using password authentication
$tc = new TorControl\TorControl(
array(
'hostname' => 'localhost',
'port' => 9051,
'password' => 'MySecr3tPassw0rd',
'authmethod' => 1
)
);
$tc->connect();
$tc->authenticate();
// Renew identity
$res = $tc->executeCommand('SIGNAL NEWNYM');
// Echo the server reply code and message
echo $res[0]['code'].': '.$res[0]['message'];
// Quit
$tc->quit();
PHP TorControl has been created by Kévin Dunglas.