Skip to content

[Workflow] Update the article about dumping workflows #11714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions workflow/dumping-workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
How to Dump Workflows
=====================

To help you debug your workflows, you can dump a representation of your workflow
with the use of a ``DumperInterface``. Use the ``GraphvizDumper`` to create a
PNG or SVG image of the workflow defined above::
To help you debug your workflows, you can generate a visual representation of
them as SVG or PNG images. First, download and install the `Graphviz project`_,
an open source graph visualization software which provides the ``dot`` command
needed to generate the images.

// dump-graph.php
$dumper = new GraphvizDumper();
echo $dumper->dump($definition);
If you are defining the workflow inside a Symfony application, run this command
to dump it as an image:

.. code-block:: terminal

$ php dump-graph.php | dot -Tsvg -o graph.svg
$ php bin/console workflow:dump workflow-name | dot -Tsvg -o graph.svg

# run this command if you prefer PNG images:
# $ php dump-graph.php | dot -Tpng -o graph.png
$ php bin/console workflow:dump workflow-name | dot -Tpng -o graph.png

# highlight 'place1' and 'place2' in the dumped workflow
$ php bin/console workflow:dump workflow-name place1 place2 | dot -Tsvg -o graph.svg

The result will look like this:

.. image:: /_images/components/workflow/blogpost.png

If you have configured your workflow with the Symfony framework, you may dump the dot file
with the ``WorkflowDumpCommand``:

.. code-block:: terminal
If you are creating workflows outside of a Symfony application, use the
``GraphvizDumper`` class to dump the workflow representation::

$ php bin/console workflow:dump name | dot -Tsvg -o graph.svg

# highlight 'place1' and 'place2' in the dumped workflow
$ php bin/console workflow:dump name place1 place2 | dot -Tsvg -o graph.svg
// Add this code to a PHP script; for example: dump-graph.php
$dumper = new GraphvizDumper();
echo $dumper->dump($definition);

.. note::
.. code-block:: terminal

The ``dot`` command is part of Graphviz. You can download it and read
more about it on `Graphviz.org`_.
# replace 'dump-graph.php' by the name of your PHP script
$ php dump-graph.php | dot -Tsvg -o graph.svg

.. _Graphviz.org: http://www.graphviz.org
.. _`Graphviz project`: http://www.graphviz.org