zwartpet / schedule-manager
Add pause and resume functionality to the laravel schedule
Requires
- php: ^8.2
- laravel/prompts: <2.0.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.20
- livewire/livewire: ^3.0
- orchestra/pest-plugin-testbench: ^3.0
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.5|^11.1
Conflicts
- laravel/framework: <11.6 || >=13.0.0
- laravel/prompts: >=2.0.0
- phpunit/phpunit: <10.5.45 || >=12.0.0
This package is auto-updated.
Last update: 2025-05-12 12:29:48 UTC
README
Adds pause and resume functionality to the Laravel schedule via command line and an admin interface (wip).
Because sometimes you just quickly want to pause a specific schedule without the need to deploy the whole application
Installation
You can install the package via composer:
composer require zwartpet/schedule-manager
Usage
Command line
Just use the schedule-manager:pause
and schedule-manager:resume
commands to pause and resume a schedule.
With the --description
option you can add a description to the pause.
The --pause-until
option will pause the schedule until the given date.
php artisan schedule-manager:pause --description="3rd party API is down" --pause-until="2027-01-01 00:00:00"
┌ Which schedule do you want to pause? ────────────────────────┐ │ › ● 0 0 * * * php artisan cache:clear │ │ ○ 0 0 1 * * php artisan cache:clear │ └──────────────────────────────────────────────────────────────┘
Using the schedule-manager:paused
command you can see all the paused schedules.
php artisan schedule-manager:paused
┌───────────────────────────────────┬─────────────────────┬───────────────────────┐ │ Paused schedule │ Paused until │ Description │ ├───────────────────────────────────┼─────────────────────┼───────────────────────┤ │ 0 0 * * * php artisan cache:clear │ 2027-01-01 00:00:00 │ 3rd party API is down │ └───────────────────────────────────┴─────────────────────┴───────────────────────┘
Additionally there is a schedule-manager:optimize
command that will cleanup the paused schedules that have expired when using the database driver which is also running on php artisan optimize
.
Configuration
This library is plug and play and works out of the box. There are some configuration options available.
For all the configuration options see the config file.
Cache driver
By default the package uses the Laravel cache to store the paused schedules.
You can change the cache store by adding SCHEDULE_MANAGER_CACHE_STORE
to your .env
which defaults to the Laravel's own CACHE_STORE
Database driver
If you want to persist the pauses even further, for instance because deploys often clear the cache, you can use the database driver.
Overwrite the SCHEDULE_MANAGER_DRIVER
in your .env
to database
and run the migrations.
UI
Publish the assets
php artisan vendor:publish --tag=schedule-manager-assets
The UI uses Laravel Livewire and is disabled by default, add SCHEDULE_MANAGER_UI_ENABLED=true
to your .env
file and install livewire.
composer require livewire/livewire
The UI is available on the /schedule-manager
route, configurable with SCHEDULE_MANAGER_UI_ROUTE
in your .env
file.
The route is protected with a Laravel Gate named schedule-manager
which you can customize with SCHEDULE_MANAGER_UI_GATE
in your .env
file.
Create the gate by adding the following to your AuthServiceProvider
, not adding this will result in a 404 error when visiting the route.
Gate::define('schedule-manager', function (User $user) { return $user->isAdmin; // or any other logic });
Testing
Pest
composer test
Pint
composer test:lint
PHPStan
composer test:types
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.