Symfony Bundle

The symfony bundle integrates php-task into your symfony application.

Features

Additional features which are implemented in this bundle.

  • Handler discovery (over task.handler-tag)
  • Different run possibilities
  • Different commands to manage and debug commands
  • Persist tasks and executions in database
  • Run statistics foreach execution of tasks

Installation

composer require php-task/task-bundle 1.0.x-dev

Usage

There are currently two ways to run tasks.

Event: kernel.terminate

The tasks will automatically executed after sending the response.

Note

Internally, the HttpKernel makes use of the fastcgi_finish_request PHP function. This means that at the moment, only the PHP FPM server API is able to send a response to the client while the server’s PHP process still performs some tasks. With all other server APIs, listeners to kernel.terminate are still executed, but the response is not sent to the client until they are all completed.

Command

The bundle provides a command to run all taks which are scheduled before run time. This command can be called by a cronjob which enables recurring tasks.

app/console task:run

Note

This option only works if you enable the storage in doctrine which will persist your tasks in a table-structure.

Configuration Reference

task:
   storage: array # One of "array" or "doctrine"
   run:
      mode: 'off' # One of "off" or "listener"