|
4 | 4 | How to Dump Workflows
|
5 | 5 | =====================
|
6 | 6 |
|
7 |
| -To help you debug your workflows, you can dump a representation of your workflow |
8 |
| -or state machine with the use of a ``DumperInterface``. Symfony provides two |
9 |
| -different dumpers, both based on Dot (see below). |
| 7 | +To help you debug your workflows, you can generate a visual representation of |
| 8 | +them as SVG or PNG images. First, install any of these free and open source |
| 9 | +applications needed to generate the images: |
10 | 10 |
|
11 |
| -Use the ``GraphvizDumper`` or ``StateMachineGraphvizDumper`` to create DOT |
12 |
| -files, or use ``PlantUmlDumper`` for PlantUML files. Both types can be converted |
13 |
| -to PNG or SVG images. |
| 11 | +* `Graphviz`_, provides the ``dot`` command; |
| 12 | +* `PlantUML`_, provides the ``plantuml.jar`` file (which requires Java). |
14 | 13 |
|
15 |
| -Images of the workflow defined above:: |
16 |
| - |
17 |
| - // dump-graph-dot.php |
18 |
| - $dumper = new GraphvizDumper(); |
19 |
| - echo $dumper->dump($definition); |
20 |
| - |
21 |
| - // dump-graph-puml.php |
22 |
| - $dumper = new PlantUmlDumper(); |
23 |
| - echo $dumper->dump($definition); |
| 14 | +If you are defining the workflow inside a Symfony application, run this command |
| 15 | +to dump it as an image: |
24 | 16 |
|
25 | 17 | .. code-block:: terminal
|
26 | 18 |
|
27 |
| - # dump DOT file in PNG image: |
28 |
| - $ php dump-graph-dot.php | dot -Tpng -o dot_graph.png |
| 19 | + # using Graphviz's 'dot' and SVG images |
| 20 | + $ php bin/console workflow:dump workflow-name | dot -Tsvg -o graph.svg |
| 21 | +
|
| 22 | + # using Graphviz's 'dot' and PNG images |
| 23 | + $ php bin/console workflow:dump workflow-name | dot -Tpng -o graph.png |
29 | 24 |
|
30 |
| - # dump DOT file in SVG image: |
31 |
| - # $ php dump-graph-dot.php | dot -Tsvg -o dot_graph.svg |
| 25 | + # using PlantUML's 'plantuml.jar' |
| 26 | + $ php bin/console workflow:dump workflow_name --dump-format=puml | java -jar plantuml.jar -p > graph.png |
32 | 27 |
|
33 |
| - # dump PlantUML in PNG image: |
34 |
| - $ php dump-graph-puml.php | java -jar plantuml.jar -p > puml_graph.png |
| 28 | + # highlight 'place1' and 'place2' in the dumped workflow |
| 29 | + $ php bin/console workflow:dump workflow-name place1 place2 | dot -Tsvg -o graph.svg |
35 | 30 |
|
36 |
| -The DOT result will look like this: |
| 31 | +The DOT image will look like this: |
37 | 32 |
|
38 | 33 | .. image:: /_images/components/workflow/blogpost.png
|
39 | 34 |
|
40 |
| -The PlantUML result: |
| 35 | +The PlantUML image will look like this: |
41 | 36 |
|
42 | 37 | .. image:: /_images/components/workflow/blogpost_puml.png
|
43 | 38 |
|
44 |
| -Inside a Symfony application, you can dump the files with those commands using |
45 |
| -``workflow:dump`` command: |
| 39 | +If you are creating workflows outside of a Symfony application, use the |
| 40 | +``GraphvizDumper`` or ``StateMachineGraphvizDumper`` class to create the DOT |
| 41 | +files and ``PlantUmlDumper`` to create the PlantUML files:: |
46 | 42 |
|
47 |
| -.. code-block:: terminal |
48 |
| -
|
49 |
| - $ php bin/console workflow:dump workflow_name | dot -Tpng -o workflow_name.png |
50 |
| - $ php bin/console workflow:dump workflow_name | dot -Tsvg -o workflow_name.svg |
51 |
| - $ php bin/console workflow:dump workflow_name --dump-format=puml | java -jar plantuml.jar -p > workflow_name.png |
52 |
| -
|
53 |
| - # highlight 'place1' and 'place2' in the dumped workflow |
54 |
| - $ php bin/console workflow:dump name place1 place2 | dot -Tsvg -o graph.svg |
55 |
| -
|
56 |
| -.. note:: |
| 43 | + // Add this code to a PHP script; for example: dump-graph.php |
| 44 | + $dumper = new GraphvizDumper(); |
| 45 | + echo $dumper->dump($definition); |
57 | 46 |
|
58 |
| - The ``dot`` command is part of Graphviz. You can download it and read |
59 |
| - more about it on `Graphviz.org`_. |
| 47 | + # if you prefer PlantUML, use this code: |
| 48 | + # $dumper = new PlantUmlDumper(); |
| 49 | + # echo $dumper->dump($definition); |
60 | 50 |
|
61 |
| - The ``plantuml.jar`` command is part of PlantUML. You can download it and |
62 |
| - read more about it on `PlantUML.com`_. |
| 51 | +.. code-block:: terminal |
63 | 52 |
|
| 53 | + # replace 'dump-graph.php' by the name of your PHP script |
| 54 | + $ php dump-graph.php | dot -Tsvg -o graph.svg |
| 55 | + $ php dump-graph.php | java -jar plantuml.jar -p > graph.png |
64 | 56 |
|
65 |
| -.. _Graphviz.org: http://www.graphviz.org |
66 |
| -.. _PlantUML.com: http://plantuml.com/ |
| 57 | +.. _`Graphviz`: http://www.graphviz.org |
| 58 | +.. _`PlantUML`: http://plantuml.com/ |
0 commit comments