/var/www/html/vendor/laminas/laminas-httphandlerrunner/src/Exception/EmitterException.php
<?php
declare(strict_types=1);
namespace Laminas\HttpHandlerRunner\Exception;
use RuntimeException;
use function sprintf;
class EmitterException extends RuntimeException implements ExceptionInterface
{
public static function forHeadersSent(string $filename, int $line): self
{
return new self(sprintf('Unable to emit response; headers already sent in %s:%d', $filename, $line));
}
public static function forOutputSent(): self
{
return new self('Output has been emitted previously; cannot emit response');
}
}
Arguments
"Unable to emit response; headers already sent in /var/www/html/vendor/symfony/var-dumper/Dumper/AbstractDumper.php:175"
/var/www/html/vendor/laminas/laminas-httphandlerrunner/src/Emitter/SapiEmitterTrait.php
use function ucwords;
trait SapiEmitterTrait
{
/**
* Checks to see if content has previously been sent.
*
* If either headers have been sent or the output buffer contains content,
* raises an exception.
*
* @throws EmitterException If headers have already been sent.
* @throws EmitterException If output is present in the output buffer.
*/
private function assertNoPreviousOutput(): void
{
$filename = null;
$line = null;
if ($this->headersSent($filename, $line)) {
assert(is_string($filename) && is_int($line));
throw EmitterException::forHeadersSent($filename, $line);
}
if (ob_get_level() > 0 && ob_get_length() > 0) {
throw EmitterException::forOutputSent();
}
}
/**
* Emit the status line.
*
* Emits the status line using the protocol version and status code from
* the response; if a reason phrase is available, it, too, is emitted.
*
* It is important to mention that this method should be called after
* `emitHeaders()` in order to prevent PHP from changing the status code of
* the emitted response.
*
* @see \Laminas\HttpHandlerRunner\Emitter\SapiEmitterTrait::emitHeaders()
*/
private function emitStatusLine(ResponseInterface $response): void
Arguments
"/var/www/html/vendor/symfony/var-dumper/Dumper/AbstractDumper.php"
175
/var/www/html/vendor/laminas/laminas-httphandlerrunner/src/Emitter/SapiEmitter.php
declare(strict_types=1);
namespace Laminas\HttpHandlerRunner\Emitter;
use Psr\Http\Message\ResponseInterface;
class SapiEmitter implements EmitterInterface
{
use SapiEmitterTrait;
/**
* Emits a response for a PHP SAPI environment.
*
* Emits the status line and headers via the header() function, and the
* body content via the output buffer.
*/
public function emit(ResponseInterface $response): bool
{
$this->assertNoPreviousOutput();
$this->emitHeaders($response);
$this->emitStatusLine($response);
$this->emitBody($response);
return true;
}
/**
* Emit the message body.
*/
private function emitBody(ResponseInterface $response): void
{
echo $response->getBody();
}
}
/var/www/html/public/index.php
$group->map('GET', '/{umiId}/last-tickets', [TicketController::class, 'findByUmiId']);
});
$router->group('/api/umi/user', function (League\Route\RouteGroup $group) {
$group->map('GET', '/{umiId}', [UmiUserController::class, 'getUserByUmiId']);
});
$router->map('GET', '/api', function (RequestInterface $request) {
$openapi = \OpenApi\Generator::scan([PROJECT_ROOT . '/src/Application', PROJECT_ROOT . '/src/UI/Http/Controller']);
header('Content-Type: application/json');
echo $openapi->toJson();
die();
});
//return $router;
$response = $router->dispatch($request);
// send the response to the browser
(new Laminas\HttpHandlerRunner\Emitter\SapiEmitter)->emit($response);
Arguments
Laminas\Diactoros\Response {#146}