Schedule Symfony Commands in your Sylius admin panel.
- See the list of planned command
- Add, edit, enable/disable or delete scheduled commands
- For each command, you have to define :
- Name
- Selected Command from the list of Symfony commands
- Based on Cron schedule expression see Cron formats
- Output Log file (optional)
- Priority (highest is priority)
- Run the Command immediately
- Download, show file size, empty log files directly from the admin panel
- Define commands with a Factory (from a Doctrine migration, for example)
-
Add the bundle and dependencies in your composer.json :
$ composer require synolia/sylius-scheduler-command-plugin
-
Enable the plugin in your
config/bundles.php
file by addSynolia\SyliusSchedulerCommandPlugin\SynoliaSyliusSchedulerCommandPlugin::class => ['all' => true],
-
Import required config in your
config/packages/_sylius.yaml
file:imports: - { resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/config.yaml" }
-
Import routing in your
config/routes.yaml
file:synolia_scheduled_command: resource: "@SynoliaSyliusSchedulerCommandPlugin/Resources/config/admin_routing.yaml" prefix: /admin
-
Copy plugin migrations to your migrations directory (e.g.
src/Migrations
) and apply them to your database:cp -R vendor/synolia/sylius-scheduler-command-plugin/src/Migrations/* src/Migrations bin/console doctrine:migrations:migrate
-
Launch Run command in your Crontab
* * * * * /_PROJECT_DIRECTORY_/bin/console synolia:scheduler-run
-
(optional) Showing humanized cron expression
composer require sivaschenko/utility-cron
- Log into admin panel
- Click on
Scheduled commands
in the Configuration section in main menu - Manage your Scheduled commands
Inside sylius fixture file config/packages/sylius_fixtures.yaml
you can add scheduled command fixtures to your suite.
sylius_fixtures:
suites:
my_fixture_suite:
fixtures:
scheduler_command:
options:
scheduled_commands:
-
name: 'Reset Sylius'
command: 'sylius:fixtures:load'
cronExpression: '0 0 * * *'
logFile: 'reset.log'
priority: 0
enabled: true
-
name: 'Cancel Unpaid Orders'
command: 'sylius:cancel-unpaid-orders'
cronExpression: '0 0 * * *'
priority: 1
enabled: false
See How to contribute.
This library is under the MIT license.
Developed by Synolia.