vaeThink2/vendor/symfony/var-dumper/Tests/Fixtures/dump_server.php

39 lines
996 B
PHP
Raw Permalink Normal View History

2020-04-01 11:42:47 +08:00
<?php
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
use Symfony\Component\VarDumper\Server\DumpServer;
use Symfony\Component\VarDumper\VarDumper;
$componentRoot = $_SERVER['COMPONENT_ROOT'];
if (!is_file($file = $componentRoot.'/vendor/autoload.php')) {
$file = $componentRoot.'/../../../../vendor/autoload.php';
}
require $file;
$cloner = new VarCloner();
$cloner->setMaxItems(-1);
$dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_STRING_LENGTH);
$dumper->setColors(false);
VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
$data = $cloner->cloneVar($var)->withRefHandles(false);
$dumper->dump($data);
});
$server = new DumpServer(getenv('VAR_DUMPER_SERVER'));
$server->start();
echo "READY\n";
$server->listen(function (Data $data, array $context, $clientId) {
dump((string) $data, $context, $clientId);
exit(0);
});