PHP code example of baohan / swoole-job
1. Go to this page and download the library: Download baohan/swoole-job 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/ */
baohan / swoole-job example snippets
$router = new \baohan\SwooleJob\Router();
$router->setPrefix("\\App\\Job\\");
$router->setExecutor("execute");
$router->setDecode(function($data) {
return json_decode($data, true);
});
$serv = new \baohan\SwooleJob\Server($router);
$serv->setSwoolePort(9505);
// custom callback event
$serv->setEvtStart(function($serv) {
echo "server start!" . PHP_EOL;
});
$serv->start();