Skip to content

Added docs for VAR_DUMPER_FORMAT #10275

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
Sep 10, 2018
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
15 changes: 12 additions & 3 deletions components/var_dumper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ current PHP SAPI:
mechanism;
* On other SAPIs, dumps are written as HTML in the regular output.

.. tip::

You can also select the output format explicitly defining the
``VAR_DUMPER_FORMAT`` environment variable and setting its value to either
``html`` or ``cli``.

.. versionadded:: 4.2
The ``VAR_DUMPER_FORMAT`` env var was introduced in Symfony 4.2.

.. note::

If you want to catch the dump output as a string, please read the
Expand Down Expand Up @@ -122,14 +131,14 @@ the :ref:`dump_destination option <configuration-debug-dump_destination>` of the
Outside a Symfony application, use the ``ServerDumper`` class::

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\VarDumper\VarDumper;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\ServerDumper;

VarDumper::setHandler(function ($var) {
$cloner = new VarCloner();
$dumper = new ServerDumper('tcp://127.0.0.1:9912');
$dumper = new ServerDumper('tcp://127.0.0.1:9912');
$dumper->dump($cloner->cloneVar($var));
});

Expand Down