1. Go to this page and download the library: Download lsr/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/ */
lsr / scheduler example snippets
declare(strict_types=1);
namespace App\Tasks;
use Lsr\Scheduler\SchedulerJobContext;
use Lsr\Scheduler\SchedulerJobInterface;
final readonly class DeleteExpiredSessionsJob implements SchedulerJobInterface
{
public function run(SchedulerJobContext $context): void
{
// Delete expired sessions or dispatch asynchronous work.
}
}
declare(strict_types=1);
namespace App\Console\Commands;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Scheduler\Attribute\AsCronTask;
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
#[AsCommand(name: 'sessions:delete-expired')]
#[AsCronTask('0 * * * *', timezone: 'Europe/Prague')]
#[AsPeriodicTask('15 minutes', arguments: ['--batch-size' => 500])]
final class DeleteExpiredSessionsCommand extends Command
{
// Normal Symfony Console command implementation.
}