PHP code example of easyswoole / job-queue
1. Go to this page and download the library: Download easyswoole/job-queue 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/ */
easyswoole / job-queue example snippets
class Queue implements \EasySwoole\JobQueue\QueueDriverInterface{
function pop(float $timeout = 3): ?\EasySwoole\JobQueue\AbstractJob
{
return null;
}
function push(\EasySwoole\JobQueue\AbstractJob $job): bool
{
return true;
}
}
$queue = new \EasySwoole\JobQueue\JobQueue(new Queue());
$http = new swoole_http_server("127.0.0.1", 9501);
$queue->attachServer($http);
$http->on("request", function ($request, $response) {
$response->header("Content-Type", "text/plain");
$response->end("Hello World\n");
});
$http->start();