1. Go to this page and download the library: Download bitwasp/stratum 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/ */
bitwasp / stratum example snippets
use \BitWasp\Stratum\Client;
use \BitWasp\Stratum\Connection;
use \BitWasp\Stratum\Request\RequestFactory;
$loop = \React\EventLoop\Factory::create();
$resolver = new \React\Dns\Resolver\Factory();
// Raw TCP, cannot perform DNS resolution
$tcp = new \React\SocketClient\TcpConnector($loop);
// TCP Connector with a DNS resolver
$dns = new \React\SocketClient\DnsConnector($tcp, $resolver->create('8.8.8.8', $loop));
// Encrypted connection
$context_options = [];
$tls = new \React\SocketClient\SecureConnector($dns, $loop, $context_options);
$requests = new RequestFactory;
$client = new Client($tls, $requests);
$host = '';
$port = '';
$client->connect($host, $port)->then(function (Connection $conn) {
/* success */
}, function (\Exception $e) {
/* error */
print_r($e->getMessage());
});
$loop->run();