eonx-com / schedule-bundle
Provides the Command Scheduling logic of Laravel in a Symfony application
Installs: 1 645
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.3
- dragonmantank/cron-expression: ^2.3
- nesbot/carbon: ^2.22
Requires (Dev)
- eonx-com/core-bundle: ^1.0
- symfony/symfony: ^4.3
This package is auto-updated.
Last update: 2021-12-27 03:31:34 UTC
README
Provides the Command Scheduling logic of Laravel in a Symfony application.
Installation
$ composer require eonx-com/schedule-bundle
Until a recipe is created for this bundle you will need to register it manually:
// config/bundles.php return [ // Other bundles... EonX\ScheduleBundle\ScheduleBundle::class => ['all' => true], ];
Usage
Register Your Scheduled Commands
To register the scheduled commands this bundle implements a concept of "schedule providers", thanks to Symfony's
autoconfigure feature, the only thing required is to create services that implement EonX\ScheduleBundle\Interfaces\ScheduleProviderInterface
.
The ScheduleInterface
passed to the schedule
method offers all the features of the Laravel Console Scheduling.
// src/Schedule/MyScheduleProvider.php use EonX\ScheduleBundle\Interfaces\ScheduleProviderInterface; final class MyScheduleProvider implements ScheduleProviderInterface { /** * Schedule command on given schedule. * * @param \EonX\ScheduleBundle\Interfaces\ScheduleInterface $schedule * * @return void */ public function schedule(ScheduleInterface $schedule): void { $schedule ->command('poc:hello-world', ['-v']) ->everyMinute() ->setMaxLockTime(120); $schedule ->command('poc:hello-world-2') ->everyFiveMinutes(); } } }
Run The Schedule
This bundle providers a console command to run the schedule:
$ php bin/console schedule:run