PHP code example of phpstreamserver / scheduler
1. Go to this page and download the library: Download phpstreamserver/scheduler 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/ */
phpstreamserver / scheduler example snippets
// server.php
use PHPStreamServer\Core\Server;
use PHPStreamServer\Plugin\Scheduler\SchedulerPlugin;
use PHPStreamServer\Plugin\Scheduler\Worker\PeriodicProcess;
$server = new Server();
$server->addPlugin(
new SchedulerPlugin(),
);
$server->addWorker(
new PeriodicProcess(
name: 'Scheduled process',
schedule: '*/1 * * * *',
onStart: function (PeriodicProcess $worker): void {
// runs every 1 minute
},
),
);
exit($server->run());
bash
$ php server.php start