Skip to content

Commit

Permalink
Error buffer (#434)
Browse files Browse the repository at this point in the history
* PHP 8 compatibility

* Save error buffer
  • Loading branch information
g105b authored Jan 14, 2021
1 parent 2e7928b commit 7cdde6b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Lifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Lifecycle implements MiddlewareInterface {
*/
public function start(bool $render = true):ResponseInterface {
ini_set("display_errors", true);
ob_start();
$server = new ServerInfo($_SERVER);

$cwd = dirname($server->getDocumentRoot());
Expand Down Expand Up @@ -114,7 +115,7 @@ public function start(bool $render = true):ResponseInterface {
$csrfProtection = new SessionTokenStore(
$sessionHandler->getStore(
"gt.csrf",
true
true
)
);

Expand Down Expand Up @@ -169,7 +170,8 @@ public function start(bool $render = true):ResponseInterface {
}
}

return $this->finish($response, $render);
$buffer = ob_get_clean();
return $this->finish($response, $buffer, $render);
}

/**
Expand Down Expand Up @@ -282,6 +284,7 @@ public function process(
*/
public static function finish(
ResponseInterface $response,
string $buffer = "",
bool $render = true
):ResponseInterface {
http_response_code($response->getStatusCode());
Expand All @@ -290,6 +293,7 @@ public static function finish(
}

if($render) {
echo $buffer;
echo $response->getBody();
}

Expand Down

0 comments on commit 7cdde6b

Please sign in to comment.