PHP code example of sam-it / proxy
1. Go to this page and download the library: Download sam-it/proxy library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sam-it / proxy example snippets
`
act\SocketClient\TcpConnector;
/** @var \React\EventLoop\LoopInterface $loop */
$loop = \React\EventLoop\Factory::create();
$connector = new TcpConnector($loop);
/** @var \React\Socket\ServerInterface $servers */
$servers = [];
$server = $servers[] = new \React\Socket\Server($loop);
$server->listen(10000, '0.0.0.0');
$forwarder = new \SamIT\Proxy\Forwarder($connector);
$forwarder->on('forward', function(\React\Stream\ReadableStreamInterface $in, \React\Stream\ReadableStreamInterface $out) {
echo "Connection set up.\n";
});
$forwarder->forwardAll($server, '192.168.37.2', 8011, 1);
echo "Listening..\n";
$loop->run();
die("Done with loop\n");