Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eac5218

Browse filesBrowse files
authored
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.
1 parent 127b35d commit eac5218
Copy full SHA for eac5218

File tree

Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-0
lines changed

‎components/var_dumper.rst

Copy file name to clipboardExpand all lines: components/var_dumper.rst
+14Lines 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, one is required to 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.