src/Viserio/Component/WebServer/Command/ServerServeCommand.php
public function handle(): int
    {
        if ($this->checkRequirements() === 1) {
            return 1;
        }

        $webServerConfig = new WebServerConfig($this->documentRoot, $this->environment, $this);

        $callback      = null;
        $disableOutput = false;
        $output        = $this->getOutput();

        if ($output->isQuiet()) {
            $disableOutput = true;
        } else {
            $callback = static function ($type, $buffer) use ($output): void {
                if (Process::ERR === $type && $output instanceof ConsoleOutputInterface) {
                    $output = $output->getErrorOutput();
                }

                $output->write($buffer, false, OutputInterface::OUTPUT_RAW);
            };
        }

        try {
            $host            = $webServerConfig->getHostname();
            $port            = $webServerConfig->getPort();
            $resolvedAddress = $webServerConfig->getDisplayAddress();

            $output->success(\sprintf(
                'Server listening on %s%s',
                $host !== '0.0.0.0' ? $host . ':' . $port : 'all interfaces, port ' . $port,
                $resolvedAddress !== null ? \sprintf(' -- see http://%s)', $resolvedAddress) : ''
            ));

            if ($webServerConfig->hasXdebug()) {
                $output->comment('Xdebug profiler trigger enabled.');
            }

            WebServer::run($webServerConfig, $disableOutput, $callback);
        } catch (\Exception $exception) {
            $this->error($exception->getMessage());

            return 1;
        }

        return 0;
    }
public function handle(): int
    {
        if ($this->checkRequirements() === 1) {
            return 1;
        }

        $webServerConfig = new WebServerConfig($this->documentRoot, $this->environment, $this);

        $callback      = null;
        $disableOutput = false;
        $output        = $this->getOutput();

        if ($output->isQuiet()) {
            $disableOutput = true;
        } else {
            $callback = static function ($type, $buffer) use ($output): void {
                if (Process::ERR === $type && $output instanceof ConsoleOutputInterface) {
                    $output = $output->getErrorOutput();
                }

                $output->write($buffer, false, OutputInterface::OUTPUT_RAW);
            };
        }

        try {
            $host            = $webServerConfig->getHostname();
            $port            = $webServerConfig->getPort();
            $resolvedAddress = $webServerConfig->getDisplayAddress();

            $output->success(\sprintf(
                'Server listening on %s%s',
                $host !== '0.0.0.0' ? $host . ':' . $port : 'all interfaces, port ' . $port,
                $resolvedAddress !== null ? \sprintf(' -- see http://%s)', $resolvedAddress) : ''
            ));

            if ($webServerConfig->hasXdebug()) {
                $output->comment('Xdebug profiler trigger enabled.');
            }

            WebServer::run($webServerConfig, $disableOutput, $callback);
        } catch (\Exception $exception) {
            $this->error($exception->getMessage());

            return 1;
        }

        return 0;
    }
{@inheritdoc}