Skip to content

Instantly share code, notes, and snippets.

@mmouih
Created January 22, 2024 02:22
Show Gist options
  • Save mmouih/2334534f62f9070250518e2389921ee1 to your computer and use it in GitHub Desktop.
Save mmouih/2334534f62f9070250518e2389921ee1 to your computer and use it in GitHub Desktop.
AsPeriodicTask usage
<?php
namespace App\Service;
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
class MyService
{
#[AsPeriodicTask(schedule: 'watchdog_attribute', frequency: '5 seconds', jitter: 10)]
public function monitoring(): void
{
// ... Monitoring logic here
}
}
<?php
namespace App\Scheduler;
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
#[AsPeriodicTask(schedule: 'watchdog_attribute', frequency: '5 seconds', jitter: 10)]
class WatchDogWithAttributeScheduleProvider
{
public function __invoke()
{
// ... Monitoring logic here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment