dump_server.php 996 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Symfony\Component\VarDumper\Cloner\Data;
  3. use Symfony\Component\VarDumper\Cloner\VarCloner;
  4. use Symfony\Component\VarDumper\Dumper\CliDumper;
  5. use Symfony\Component\VarDumper\Server\DumpServer;
  6. use Symfony\Component\VarDumper\VarDumper;
  7. $componentRoot = $_SERVER['COMPONENT_ROOT'];
  8. if (!is_file($file = $componentRoot.'/vendor/autoload.php')) {
  9. $file = $componentRoot.'/../../../../vendor/autoload.php';
  10. }
  11. require $file;
  12. $cloner = new VarCloner();
  13. $cloner->setMaxItems(-1);
  14. $dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_STRING_LENGTH);
  15. $dumper->setColors(false);
  16. VarDumper::setHandler(function ($var) use ($cloner, $dumper) {
  17. $data = $cloner->cloneVar($var)->withRefHandles(false);
  18. $dumper->dump($data);
  19. });
  20. $server = new DumpServer(getenv('VAR_DUMPER_SERVER'));
  21. $server->start();
  22. echo "READY\n";
  23. $server->listen(function (Data $data, array $context, $clientId) {
  24. dump((string) $data, $context, $clientId);
  25. exit(0);
  26. });