Recommend this page to a friend! |
Classes of Emil Kilhage | Symfony Task bundle | README.md | Download |
|
Downloadtask-bundleProvides a simple framework to manage scheduling and execution of tasks Symfony application. PrerequisiteThis bundle requires cron to be installed on the server to be able to execute scheduled tasks InstallationAdd the
Add the GloobyTaskBundle to your application's kernel:
Create this file /etc/cron.d/glooby_scheduler_run
DocumentationCreate a executable TaskTo setup a new runnable task you should follow these steps Implement the TaskInterfaceexample: src/Glooby/Api/TaskBundle/Task/PingTask.php
Add a service for your task
Try and run the task trough cli
Setup Scheduled taskTo setup a new schedule you should follow the steps below Make your service runnableFollow the steps in Create a executable Task Tag your serviceBy tagging your service with the glooby.scheduled_task tag it will be treated as a scheduled task example: src/Glooby/Api/TaskBundle/Resources/config/services.yml
Annotate your classAnnotate your class with this annotation: Glooby\TaskBundle\Annotation\Schedule ParametersintervalThe first parameter to the annotation is defaulted to the interval parameter. In this parameter you configure the interval that the service should be executed. The interval is a string of five or optional six subexpressions that describe details of the schedule. The syntax is based on the Linux cron daemon definition.
This is the only required parameter
Here you have several shortcuts that you can use instead for most common use cases | value | interval | |:---------------:|:------------:| | @yearly | 0 0 1 1 * | | @annually | 0 0 1 1 * | | @monthly | 0 0 1 | | @weekly | 0 0 0 | | @daily | 0 0 * | | @hourly | 0 | | @semi_hourly | /30 * | | @quarter_hourly | /15 * | | | |
paramsThe params that should be used when calling
activePhe active parameter tells if the schedule should be active or not, default=true
Sync schedules to the database, this has to be run after each update
Running the TestsInstall the dependencies:
Then, run the test suite:
ContributingSee CONTRIBUTING file. LicenseThis bundle is released under the MIT license. See the complete license in the bundle: LICENSE.md |