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.