8000 feature #10204 Explain dump server usage outside of Symfony (skunkbad… · symfony/symfony-docs@73f8755 · GitHub
[go: up one dir, main page]

Skip to content

Commit 73f8755

Browse files
committed
feature #10204 Explain dump server usage outside of Symfony (skunkbad, weaverryan)
This PR was merged into the 4.1 branch. Discussion ---------- Explain dump server usage outside of Symfony Took hours for me to figure out how to use the dump server outside of Symfony, because there is no mention that it can be done, and one must use the ServerDumper class to make it work. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintaine 8000 d branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- d360452 minor language tweak eac5218 Explain dump server usage outside of Symfony
2 parents a1564e2 + d360452 commit 73f8755

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/var_dumper.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ Inside a Symfony application, the output of the dump server is configured with
119119
the :ref:`dump_destination option <configuration-debug-dump_destination>` of the
120120
``debug`` package.
121121

122+
Outside a Symfony application, use the ``ServerDumper`` class:
123+
124+
require __DIR__.'/vendor/autoload.php';
125+
126+
use Symfony\Component\VarDumper\VarDumper;
127+
use Symfony\Component\VarDumper\Cloner\VarCloner;
128+
use Symfony\Component\VarDumper\Dumper\ServerDumper;
129+
130+
VarDumper::setHandler(function ($var) {
131+
$cloner = new VarCloner();
132+
$dumper = new ServerDumper('tcp://127.0.0.1:9912');
133+
$dumper->dump($cloner->cloneVar($var));
134+
});
135+
122136
DebugBundle and Twig Integration
123137
--------------------------------
124138

0 commit comments

Comments
 (0)
0