filp / whoops

PHP errors for cool kids
http://filp.github.io/whoops/
MIT License
13.19k stars 604 forks source link

PrettyPageHandler to html not working #755

Open btxtiger opened 1 year ago

btxtiger commented 1 year ago

To reproduce: I have a very basic composer project (PHP 8.2.4, basic common extensions enabled).

While just having this code in index.php and running it from command line via php -f index.php, the $html is always an empty string.

$e = new \Exception('This is a test exception!');
$whoops = new \Whoops\Run;
$whoops->allowQuit(false);
$whoops->writeToOutput(false);
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$html = $whoops->handleException($e);

error_log($html); // => ""
bart-jaskulski commented 1 year ago

Hi @btxtiger!

I think, you need to add following call in your snippet. Without this using PrettyPageHandler is ignored in CLI context. See this piece of source code.

$whoops->handleUnconditionally(true);