Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/natepage/schedule-bundle
https://github.com/natepage/schedule-bundle
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/natepage/schedule-bundle
- Owner: natepage
- Created: 2019-08-12T03:30:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-15T14:59:39.000Z (over 5 years ago)
- Last Synced: 2024-04-20T05:40:37.752Z (9 months ago)
- Language: PHP
- Size: 48.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ScheduleBundle
Provides the Command Scheduling logic of Laravel in a Symfony application
## Installation
```bash
$ composer require loyaltycorp/schedule-bundle
```Until a recipe is created for this bundle you will need to register it manually:
```php
// config/bundles.phpreturn [
// Other bundles...
LoyaltyCorp\Schedule\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 `LoyaltyCorp\Schedule\ScheduleBundle\Interfaces\ScheduleProviderInterface`.
The `ScheduleInterface` passed to the `schedule` method offers all the features of the [Laravel Console Scheduling][1].```php
// src/Schedule/MyScheduleProvider.phpuse LoyaltyCorp\Schedule\ScheduleBundle\Interfaces\ScheduleProviderInterface;
final class MyScheduleProvider implements ScheduleProviderInterface
{
/**
* Schedule command on given schedule.
*
* @param \Loyaltycorp\Schedule\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:
```bash
$ php bin/console schedule:run
```[1]: https://laravel.com/docs/5.8/scheduling