Download the PHP package vtitar/background-tasks-symfony without Composer
On this page you can find all versions of the php package vtitar/background-tasks-symfony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vtitar/background-tasks-symfony
More information about vtitar/background-tasks-symfony
Files in vtitar/background-tasks-symfony
Package background-tasks-symfony
Short Description Symfony BackgroundTasksBundle. Create and process tasks that will be executed via cron. Could be configured time when execute, separate process for specific task groups.
License MIT
Informations about the package background-tasks-symfony
1. Bundle overview
Symfony BackgroundTasksBundle. Create and process tasks that will be executed via cron. Could be configured time when task should be executed, separate process for specific task groups.
2. Installation
Install bundle
composer require vtitar/background-tasks-symfony
Create db after installation
./bin/console doctrine:schema:update
3. Configuration
- Add new cron config to crontab - will execute all tasks without specific group
* * * * * /usr/bin/flock -n /home/project/path/var/locks/cron-background-tasks.lock /home/project/path/bin/console tit:background-task:run > /home/project/path/var/log/cron-background-tasks.log 2>&1
- In case you need to have separate process for some tasks to not block/wait main process - configure separate cron for tasks with specific group only
* * * * * /usr/bin/flock -n /home/project/path/var/locks/cron-background-tasks-group-test.lock /home/project/path/bin/console tit:background-task:run --group_code=test-group > /home/project/path/var/log/cron-background-tasks-group-test.log 2>&1
4. How to use
4.1 Add new entity to execution list
4.1.1 Add via entityManager
New entity could be added via entityManager like
4.1.2 Add via BackgroundTaskManager
Or BackgroundTaskManager could be used. Add tit.background_tasks.manager.background_task service
to your service where you want to use it. Add to controller like
And add new task
4.2 Add service and function that should process task
4.2.1 Service should be public
4.2.2 Add function that will process task
4.3 Errors checking
You could easily check is task executed okay via db background_task.status column.
- error - status should be -1. Error should be saved in
background_task.last_errorcolumn. - if you want to add task back to queue - set
statusto 0
All versions of background-tasks-symfony with dependencies
symfony/framework-bundle Version ^7
doctrine/orm Version ^2.17
symfony/monolog-bundle Version ^3.0
doctrine/doctrine-bundle Version ^2.13