1. Go to this page and download the library: Download phlib/beanstalk 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/ */
use Phlib\Beanstalk\Connection;
use Phlib\Beanstalk\Pool;
$connections = [
new Connection('10.0.0.1'),
new Connection('10.0.0.2'),
new Connection('10.0.0.3'),
new Connection('10.0.0.4'),
];
$logger = new MyLogger();
$pool = new Pool($connections, 120, $logger);
$pool->useTube('my-tube');
$pool->put(array('my' => 'jobData1')); // )
$pool->put(array('my' => 'jobData2')); // )-> distributed between random servers
$pool->put(array('my' => 'jobData3')); // )
use Phlib\Beanstalk\Factory;
use Phlib\Beanstalk\Pool;
$connections = (new Factory())->createConnections([
['host' => '10.0.0.1', 'enabled' => true],
['host' => '10.0.0.2', 'enabled' => false],
['host' => '10.0.0.3', 'enabled' => true],
]);
$logger = new MyLogger();
$pool = new Pool($connections, 120, $logger);