https://github.com/phpstreamserver/scheduler
[READ ONLY] Scheduler Plugin for PHPStreamServer
https://github.com/phpstreamserver/scheduler
phpstreamserver
Last synced: 11 months ago
JSON representation
[READ ONLY] Scheduler Plugin for PHPStreamServer
- Host: GitHub
- URL: https://github.com/phpstreamserver/scheduler
- Owner: phpstreamserver
- Created: 2024-11-22T17:41:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-27T18:07:05.000Z (over 1 year ago)
- Last Synced: 2024-12-27T19:19:02.585Z (over 1 year ago)
- Topics: phpstreamserver
- Language: PHP
- Homepage: https://phpstreamserver.dev
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Scheduler Plugin for PHPStreamServer



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
```bash
$ composer require phpstreamserver/core phpstreamserver/scheduler
```
### Configure
Here is an example of a simple server configuration with scheduler.
```php
// 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());
```
### Run
```bash
$ php server.php start
```