I tried to use the scheduler library. My Symfony version is 6.3.*.
I want to declare the following scheduler: Something seems to go wrong, and my scheduler is not declared. Also, the debug:scheduler does not seem to exist.
<?php
namespace App\Scheduler;
use App\Message\MiseAJourEtatMessage;
use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;
#[AsSchedule(name: 'default')]
class MainSchedule implements ScheduleProviderInterface {
public function getSchedule(): Schedule {
$schedule = new Schedule();
return $schedule->add(RecurringMessage::every('4s', new MiseAJourEtatMessage()));
}
}
Something seems to go wrong, as the command:
php bin/console messenger:consume scheduler_default
as the following result:
The receiver "scheduler_start" does not exist.
I made sure the following commands were run without errors:
composer require symfony/scheduler symfony/messenger
My composer.json is correctly updated with: "symfony/scheduler": "6.4.*"
.
The folder vendor/symfony/scheduler is created, and I can find the declaration of the debug:scheduler method in Command/DebugCommand.php
#[AsCommand(name: 'debug:scheduler', description: 'List schedules and their recurring messages')] final class
DebugCommand extends Command {
I tried to run:
symfony console debug:scheduler
The following message is printed in the console:
Command "debug:scheduler" is not defined.
Ok so i solved it. It was in fact errors in the packages i listed in my composer.json. I created another project and imported the scheduler package, then compared the two composer.json. I was able to see the packages at fault.
Also, the '4s' in my calling of the method "every()" isn't correct and will generate an error when using 'symfony console debug:scheduler'.
I simply replaced it by the correct format : '4 seconds'.