services.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\DependencyInjection\Loader\Configurator;
  11. use Symfony\Bridge\Monolog\Command\ServerLogCommand;
  12. use Symfony\Bridge\Twig\Extension\DumpExtension;
  13. use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
  14. use Symfony\Component\HttpKernel\EventListener\DumpListener;
  15. use Symfony\Component\VarDumper\Cloner\VarCloner;
  16. use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor;
  17. use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor;
  18. use Symfony\Component\VarDumper\Command\ServerDumpCommand;
  19. use Symfony\Component\VarDumper\Dumper\CliDumper;
  20. use Symfony\Component\VarDumper\Dumper\ContextProvider\CliContextProvider;
  21. use Symfony\Component\VarDumper\Dumper\ContextProvider\RequestContextProvider;
  22. use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
  23. use Symfony\Component\VarDumper\Dumper\ContextualizedDumper;
  24. use Symfony\Component\VarDumper\Dumper\HtmlDumper;
  25. use Symfony\Component\VarDumper\Server\Connection;
  26. use Symfony\Component\VarDumper\Server\DumpServer;
  27. return static function (ContainerConfigurator $container) {
  28. $container->parameters()
  29. ->set('env(VAR_DUMPER_SERVER)', '127.0.0.1:9912')
  30. ;
  31. $container->services()
  32. ->set('twig.extension.dump', DumpExtension::class)
  33. ->args([
  34. service('var_dumper.cloner'),
  35. service('var_dumper.html_dumper'),
  36. ])
  37. ->tag('twig.extension')
  38. ->set('data_collector.dump', DumpDataCollector::class)
  39. ->public()
  40. ->args([
  41. service('debug.stopwatch')->ignoreOnInvalid(),
  42. service('debug.file_link_formatter')->ignoreOnInvalid(),
  43. param('kernel.charset'),
  44. service('request_stack'),
  45. null, // var_dumper.cli_dumper or var_dumper.server_connection when debug.dump_destination is set
  46. ])
  47. ->tag('data_collector', [
  48. 'id' => 'dump',
  49. 'template' => '@Debug/Profiler/dump.html.twig',
  50. 'priority' => 240,
  51. ])
  52. ->set('debug.dump_listener', DumpListener::class)
  53. ->args([
  54. service('var_dumper.cloner'),
  55. service('var_dumper.cli_dumper'),
  56. null,
  57. ])
  58. ->tag('kernel.event_subscriber')
  59. ->set('var_dumper.cloner', VarCloner::class)
  60. ->public()
  61. ->set('var_dumper.cli_dumper', CliDumper::class)
  62. ->args([
  63. null, // debug.dump_destination,
  64. param('kernel.charset'),
  65. 0, // flags
  66. ])
  67. ->set('var_dumper.contextualized_cli_dumper', ContextualizedDumper::class)
  68. ->decorate('var_dumper.cli_dumper')
  69. ->args([
  70. service('var_dumper.contextualized_cli_dumper.inner'),
  71. [
  72. 'source' => inline_service(SourceContextProvider::class)->args([
  73. param('kernel.charset'),
  74. param('kernel.project_dir'),
  75. service('debug.file_link_formatter')->nullOnInvalid(),
  76. ]),
  77. ],
  78. ])
  79. ->set('var_dumper.html_dumper', HtmlDumper::class)
  80. ->args([
  81. null,
  82. param('kernel.charset'),
  83. 0, // flags
  84. ])
  85. ->call('setDisplayOptions', [
  86. ['fileLinkFormat' => service('debug.file_link_formatter')->ignoreOnInvalid()],
  87. ])
  88. ->set('var_dumper.server_connection', Connection::class)
  89. ->args([
  90. '', // server host
  91. [
  92. 'source' => inline_service(SourceContextProvider::class)->args([
  93. param('kernel.charset'),
  94. param('kernel.project_dir'),
  95. service('debug.file_link_formatter')->nullOnInvalid(),
  96. ]),
  97. 'request' => inline_service(RequestContextProvider::class)->args([service('request_stack')]),
  98. 'cli' => inline_service(CliContextProvider::class),
  99. ],
  100. ])
  101. ->set('var_dumper.dump_server', DumpServer::class)
  102. ->args([
  103. '', // server host
  104. service('logger')->nullOnInvalid(),
  105. ])
  106. ->tag('monolog.logger', ['channel' => 'debug'])
  107. ->set('var_dumper.command.server_dump', ServerDumpCommand::class)
  108. ->args([
  109. service('var_dumper.dump_server'),
  110. [
  111. 'cli' => inline_service(CliDescriptor::class)->args([service('var_dumper.contextualized_cli_dumper.inner')]),
  112. 'html' => inline_service(HtmlDescriptor::class)->args([service('var_dumper.html_dumper')]),
  113. ],
  114. ])
  115. ->tag('console.command', ['command' => 'server:dump'])
  116. ->set('monolog.command.server_log', ServerLogCommand::class)
  117. ->tag('console.command', ['command' => 'server:log'])
  118. ;
  119. };