thhan / schedule-bundle
thhan ScheduleBundle
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1.3
- mtdowling/cron-expression: ^1.2.3
This package is auto-updated.
Last update: 2024-12-25 05:27:09 UTC
README
This bundle offers you the possibility to add console commands to a cronjob with a simple function.
Installation
composer req thhan/schedule-bundle
Register this bundle manually.
// config/bundles.php return [ // Other bundles... Thhan\ScheduleBundle\ScheduleBundle::class => ['all' => true], ];
Server configuration
Finally you create a cronjob on the server that executes the "schedule:run" command every minute.
* * * * * {path_to_symfony}/bin/console schedule:run >> /dev/null 2>&1
Usage
Add the Trait Schedule class to your console command. Extend the configuration function with the function "addCron". As parameter you pass a string or an array of strings with the formatting of cron jobs.
use Thhan\ScheduleBundle\Command\Schedule; class YourCommand extends Command { use Schedule; public function configure() { $this->setName('app:test') ->addCron('30 3 * * *') ->addCron([ '*/10 * * * *', '0 22 * * 1' ]); } }
Planned
- add jobs via configuration
- add logger for output