draw/cron-job
Manage cron jobs stored in the database: queue due jobs and execute them via Symfony Messenger workers. Includes console commands to enqueue due jobs or run by name, optional Sonata Admin pages, and Doctrine ORM mapping configuration.
This library is used to manage and process cron jobs from the database.
The cron are sent to a queue and processed by a worker via symfony messenger.
The package can be enabled as follows:
NOTE: Below are the default configs which can be overwritten by your needs.
draw_framework_extra:
# ...
cron_job:
enabled: true
doctrine:
orm:
mappings:
DrawCronJob:
is_bundle: false
type: attribute
dir: ...
prefix: Draw\Component\CronJob\Entity
NOTE: The following services are available:
- draw.cron_job.command.queue_cron_job_by_name_command: Draw\Component\CronJob\Command\QueueCronJobByNameCommand
- draw.cron_job.command.queue_due_cron_jobs_command: Draw\Component\CronJob\Command\QueueDueCronJobsCommand
- draw.cron_job.cron_job_processor: Draw\Component\CronJob\CronJobProcessor
- draw.cron_job.message_handler.execute_cron_job_message_handler: Draw\Component\CronJob\MessageHandler\ExecuteCronJobMessageHandler
draw_sonata_integration:
cron_job:
enabled: true
admin:
cron_job:
group: Cron Job
entity_class: Draw\Component\CronJob\Entity\CronJob
controller_class: Draw\Bundle\SonataIntegrationBundle\CronJob\Controller\CronJobController
icon: fas fa-clock
label: Cron Job
pager_type: simple
show_in_dashboard: true
translation_domain: SonataAdminBundle
cron_job_execution:
group: Cron Job
entity_class: Draw\Component\CronJob\Entity\CronJobExecution
controller_class: Draw\Bundle\SonataIntegrationBundle\CronJob\Controller\CronJobExecutionController
icon: null
label: Cron Job Execution
pager_type: simple
show_in_dashboard: true
translation_domain: SonataAdminBundle
You need to configure the routing for the messenger component for the message that will be used to process the cron jobs.
framework:
messenger:
routing:
Draw\Component\CronJob\Message\ExecuteCronJobMessage: 'async'
Once the package is enabled, a new admin page will be available - Cron Job. The package also provides 2 console commands:
How can I help you explore Laravel packages today?