orisai/nette-scheduler

Orisai Scheduler integration for Nette

1.2.1 2024-06-21 13:38 UTC

This package is auto-updated.

Last update: 2024-12-21 14:53:19 UTC


README

Orisai
Nette Scheduler

Orisai Scheduler integration for Nette

📄 Check out our documentation.

💸 If you like Orisai, please make a donation. Thank you!

Register scheduler extension

extensions:
	orisai.scheduler: OriNette\Scheduler\DI\SchedulerExtension

Create service which will be run as a job

namespace Example;

class ExampleJobService
{

	public function run(): void
	{
		// Do something
	}

}
orisai.scheduler:
	jobs:
		-
			expression: * * * * *
			callback: [@example.job.service, 'run']

services:
	example.job.service: Example\ExampleJobService

Create script with scheduler setup (e.g. bin/scheduler.php)

use Orisai\Scheduler\Scheduler;

require __DIR__ . '/../vendor/autoload.php';

$configurator = Bootstrap::boot();
$container = $configurator->createContainer();
$scheduler = $container->getByType(Scheduler::class);

$scheduler->run();

Configure crontab to run your script each minute

* * * * * cd path/to/project && php bin/scheduler.php >> /dev/null 2>&1

Looking for more? Documentation is here.