Slide 1

Slide 1 text

Simplified Processes With Symfony Workflow

Slide 2

Slide 2 text

Who Am I? I am Brazilian but living in Ireland I am a Symfony Lover ❤ You can find me at @Bruno_HSouza on Twitter Or @bruno7strings on Instagram

Slide 3

Slide 3 text

AGENDA What Is a Process and Symfony Workflow? How to use Symfony Workflow? Workflow VS State Machine? The Real Case Scenario Generating Graphs Automatically

Slide 4

Slide 4 text

What is a Process? A set of interrelated actions and activities performed to achieve a specified set of products, results, or services. A Guide to the Project Management Body of Knowledge (PMBOK® Guide). Project Management Institute, 2017

Slide 5

Slide 5 text

1 2 3 4 5 Enjoy The Talks Arriving in the event venue Get a Transport Get Out From Home How To Get To The Symfony Con 2023? The Steps Of The Going Process Select Your Room

Slide 6

Slide 6 text

What is the Symfony Workflow? A workflow is a model of a process in the application

Slide 7

Slide 7 text

What is the Symfony Workflow? A workflow is a model of a process in the application Consists of places and actions to get from one place to another

Slide 8

Slide 8 text

What is the Symfony Workflow? A workflow is a model of a process in the application Consists of places and actions to get from one place to another Terminology definition: Place - step or stage in the process Transition - is the action of getting from one place to another Definition - set of places and transactions Marking - current state position Marking Store - a place to store the state

Slide 9

Slide 9 text

Init Transition Start Place A Symfony Workflow Terminology Transition 2 Place B Transition 3

Slide 10

Slide 10 text

Place Trans ition Place Trans ition Place Enjoy The Talks Select Your Room Arriving in the event venue Get a Transport Get Out From Home How To Get To The Symfony Con 2023? The Symfony Workflow Terminology

Slide 11

Slide 11 text

Place Trans action Place Trans action Place Enjoy The Talks Select Your Room Arriving in the event venue Get a Transport Get Out From Home How To Get To The Symfony Con 2023? The Symfony Workflow Terminology Marking

Slide 12

Slide 12 text

Place Trans action Place Trans action Place Enjoy The Talks Select Your Room Arriving in the event venue Get a Transport Get Out From Home How To Get To The Symfony Con 2023? The Symfony Workflow Terminology Definition

Slide 13

Slide 13 text

How To Use The Symfony Workflow? How to install and configure the component in our applications

Slide 14

Slide 14 text

Installation

Slide 15

Slide 15 text

How to find the Workflow service class in the project?

Slide 16

Slide 16 text

The Symfony Workflow configuration options To know all the configuration options from the component:

Slide 17

Slide 17 text

The config:dump-reference workflows response

Slide 18

Slide 18 text

Workflow VS State Machine What is the difference between the workflow and state machine types?

Slide 19

Slide 19 text

Workflow VS State Machines Workflows can be in more than one place at the same time, the multiple-state terminology

Slide 20

Slide 20 text

Workflow VS State Machines Workflows can be in more than one place at the same time, the multiple-state terminology The state machine uses the single-state terminology. The order can be only in a single place per time

Slide 21

Slide 21 text

Workflow VS State Machines Workflows can be in more than one place at the same time, the multiple-state terminology The state machine uses the single-state terminology. The order can be only in a single place per time To apply a transition, workflows require that the object is in all the previous places of the transition

Slide 22

Slide 22 text

Workflow VS State Machines Workflows can be in more than one place at the same time, the multiple-state terminology The state machine uses the single-state terminology. The order can be only in a single place per time To apply a transition, workflows require that the object is in all the previous places of the transition To apply a transition, state machines only require that the object is at least in one of those previous places

Slide 23

Slide 23 text

MarkingStoreInterface

Slide 24

Slide 24 text

MarkingStoreInterface

Slide 25

Slide 25 text

The main difference is the way that Symfony Workflow stores the place data: Workflow: App\Entity\SalesOrder::getCurrentPlace(): ?array State Machine: App\Entity\SalesOrder::getCurrentPlace(): ?string The difference between workflow and state machine

Slide 26

Slide 26 text

The Real Case Scenario How we are using the Symfony Workflow in our projects?

Slide 27

Slide 27 text

>= 22 valid status More than 7 applications involved More than 5 different scenarios 2 of the main applications are using Symfony Workflow Let’s talk about the entry application The sales order flow in the company

Slide 28

Slide 28 text

1 Sales Order Creation Request 2 Order Validation 3 Accepted 4 Persist the Order 7 Complete 6 Processing 5 Send to the next application The Sales Order Flow The happy path for the order flow in the entry application

Slide 29

Slide 29 text

The Symfony Workflow Definition

Slide 30

Slide 30 text

The Symfony Workflow Transitions

Slide 31

Slide 31 text

The Symfony Workflow Dependency Injection

Slide 32

Slide 32 text

The Symfony WorkflowInterface

Slide 33

Slide 33 text

The Symfony Workflow Use Case

Slide 34

Slide 34 text

The Symfony Workflow Use Case

Slide 35

Slide 35 text

The DDD Structure How to apply the Symfony Workflow in a DDD architecture

Slide 36

Slide 36 text

The DDD archicteture

Slide 37

Slide 37 text

DON’T TALK TO ME OR MY DOMAIN EVER AGAIN The DDD archicteture Evans, E. (2004) Domain-Driven Design. p. 70 DDD only really requires one isolated layer which is the Domain Layer. The "domain layer" is the manifestation of the domain model and all directly related design elements.

Slide 38

Slide 38 text

The DDD archicteture

Slide 39

Slide 39 text

The DDD archicteture

Slide 40

Slide 40 text

The DDD archicteture

Slide 41

Slide 41 text

Generating graphs How to use the Symfony Workflow to generate graphs automatically

Slide 42

Slide 42 text

It is possible to generate a visual representation of them as SVG or PNG images using: Graphviz, provides the dot command; Mermaid CLI, provides the mmdc command; PlantUML, provides the plantuml.jar file (which requires Java). Generating graphs

Slide 43

Slide 43 text

Generating graphs

Slide 44

Slide 44 text

From the Symfony 6.4 version, it is possible to use some metadata tags to style the workflow graphs: for places: bg_color: a color; description: a string that describes the state. for transitions: label: a string that replaces the name of the transition; color: a color; arrow_color: a color. Generating graphs - Stylish

Slide 45

Slide 45 text

Generating graphs - Stylish

Slide 46

Slide 46 text

Generating graphs - Stylish

Slide 47

Slide 47 text

Generating graphs - Stylish

Slide 48

Slide 48 text

Thank You!