Symfony 4 was released on November 30th.
Update now to the best Symfony ever!

You are browsing the Symfony 4 documentation, which changes significantly from Symfony 3.x. If your app doesn't use Symfony 4 yet, browse the Symfony 3.4 documentation.

Workflow

4.0 version
Maintained Unmaintained
3.2

Workflow

A workflow is a model of a process in your application. It may be the process of how a blog post goes from draft, review and publish. Another example is when a user submits a series of different forms to complete a task. Such processes are best kept away from your models and should be defined in configuration.

A definition of a workflow consist of places and actions to get from one place to another. The actions are called transitions. A workflow does also need to know each object's position in the workflow. That marking store writes to a property of the object to remember the current place.

Note

The terminology above is commonly used when discussing workflows and Petri nets

The Workflow component does also support state machines. A state machine is a subset of a workflow and its purpose is to hold a state of your model. Read more about the differences and specific features of state machine in Workflows as State Machines.

Examples

The simplest workflow looks like this. It contains two places and one transition.

_images/simple.png

Workflows could be more complicated when they describe a real business case. The workflow below describes the process to fill in a job application.

_images/job_application.png

When you fill in a job application in this example there are 4 to 7 steps depending on the what job you are applying for. Some jobs require personality tests, logic tests and/or formal requirements to be answered by the user. Some jobs don't. The GuardEvent is used to decide what next steps are allowed for a specific application.

By defining a workflow like this, there is an overview how the process looks like. The process logic is not mixed with the controllers, models or view. The order of the steps can be changed by changing the configuration only.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.