Symfony 1 min read

Symfony 8.2 Introduces Native Attribute-Based Workflow Support

Symfony 8.2 enables developers to define state machine configurations directly within PHP classes using attributes, reducing reliance on external YAML or XML files.

Symfony 8.2 adds native support for attribute-based workflows. You can now define state machine configurations directly inside PHP classes using attributes, dropping external configuration files like YAML or XML entirely.

This update follows the pattern established by other components that have already transitioned to attribute-based configurations. You can apply specific attributes to class properties or methods to designate them as parts of a workflow, including defining places, transitions, and guard expressions. Doing this reduces context switching between your application code and separate configuration files.

Placing the configuration directly in the class context brings several benefits. It improves IDE support, enabling better autocompletion and static analysis while keeping the configuration visible right next to the logic it governs.

File-based definitions are not going away. Existing workflow configurations continue to be supported so you don't face breaking changes in projects that already use them. This lets you run a gradual migration or mix both methods depending on your project requirements.

You can check out the official project manual for documentation on the updated workflow component implementation.