1. Go to this page and download the library: Download got/stark 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/ */
got / stark example snippets
tark\DaemonFactory;
use Stark\Daemon\Consumer\AbstractConsumer;
use Stark\Daemon\Worker;
class MyConsumer extends AbstractConsumer {
public function consume(Worker $worker, $data) {
// ...
return true;
}
}
$daemon = DaemonFactory::consumerOnly(new MyConsumer());
$daemon->setWorkerCount(3);
$daemon->setMaxRunCount(50000);
$daemon->setPort(9101);
$daemon->setName("consumer-self");
$daemon->setWorkingDirectory("/tmp");
$daemon->start();
tark\Daemon\Consumer\AbstractConsumer;
use Stark\DaemonFactory;
use Stark\Daemon\Worker;
class MyConsumer extends AbstractConsumer {
public function consume(Worker $worker, $data) {
if ($data == false) {
return false;
}
//... $data from redis queue-0
return true;
}
}
$daemon = DaemonFactory::consumeRedis(new MyConsumer(), "127.0.0.1", "9004", "queue-0");
$daemon->setWorkerCount(3);
$daemon->setMaxRunCount(500000);
$daemon->setPort(9102);
$daemon->setName("consumer-redis");
$daemon->start();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.