Skip to content

[READ ONLY] Scheduler Plugin for PHPStreamServer

Notifications You must be signed in to change notification settings

phpstreamserver/scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPStreamServer logo

Scheduler Plugin for PHPStreamServer

PHP >=8.2 Version Downloads

The Scheduler Plugin for PHPStreamServer extends the core functionality by providing a scheduling capability, allowing you to run programs or tasks at specific intervals, much like a traditional cron job.

Features

  • Defining schedules using cron syntax.
  • Defining schedules using relative date format as supported by \DateInterval.

Install

$ composer require phpstreamserver/core phpstreamserver/scheduler

Configure

Here is an example of a simple server configuration with scheduler.

// server.php

use PHPStreamServer\Core\Server;
use PHPStreamServer\Plugin\Scheduler\PeriodicProcess;
use PHPStreamServer\Plugin\Scheduler\SchedulerPlugin;

$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());

Run

$ php server.php start

About

[READ ONLY] Scheduler Plugin for PHPStreamServer

Topics

Resources

Stars

Watchers

Forks

Languages