vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php line 53

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <[email protected]>
  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\Runtime\Runner\Symfony;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\HttpKernel\HttpKernelInterface;
  14. use Symfony\Component\HttpKernel\Kernel;
  15. use Symfony\Component\HttpKernel\TerminableInterface;
  16. use Symfony\Component\Runtime\RunnerInterface;
  17. /**
  18. * @author Nicolas Grekas <[email protected]>
  19. */
  20. class HttpKernelRunner implements RunnerInterface
  21. {
  22. public function __construct(
  23. private readonly HttpKernelInterface $kernel,
  24. private readonly Request $request,
  25. private readonly bool $debug = false,
  26. ) {
  27. }
  28. public function run(): int
  29. {
  30. $response = $this->kernel->handle($this->request);
  31. if (Kernel::VERSION_ID >= 60400) {
  32. $response->send(false);
  33. if (\function_exists('fastcgi_finish_request') && !$this->debug) {
  34. fastcgi_finish_request();
  35. } elseif (\function_exists('litespeed_finish_request') && !$this->debug) {
  36. litespeed_finish_request();
  37. } else {
  38. Response::closeOutputBuffers(0, true);
  39. flush();
  40. }
  41. } else {
  42. $response->send();
  43. }
  44. if ($this->kernel instanceof TerminableInterface) {
  45. $this->kernel->terminate($this->request, $response);
  46. }
  47. return 0;
  48. }
  49. }