Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Save the result of Whoops PrettyPageHandler

I'm using the Whoops error library (and loving it) on dev to show the PrettyPageHandler like so:

if (ENVIRONMENT == 'local') {
    $whoops = new \Whoops\Run;
    $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
    $whoops->register();
}

For live I'm using the CallbackHandler to show the end user a "user friendly" error message.

Is there anyway to save the result/output of PrettyPageHandler into a database or even to the filesystem? My thinking is to show the end user the friendly error page but record the error at the same time using the PrettyPageHandler to look back at and debug the error the user got.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Like described in the documentation:

$run->pushHandler(function($exception, $inspector, $run) {
    var_dump($exception->getMessage());
    return Handler::DONE;
});

replace var_dump($exception->getMessage()); with your custom code to save to database or file log.

https://github.com/filp/whoops/blob/master/docs/API%20Documentation.md#core-handlers-1

Edit1:

To use the PrettyPageHandler to save the log, create a custom handler extending from PrettyPageHandler, and in the place where the handle return the formated response before return the response to the user, save in database or filesytem in desired format.

about 4 years ago · Santiago Trujillo Relatório

0

You can do something like this:

<?php

class PrettyErrorLogger extends \Whoops\Handler\PrettyPageHandler
{
    public function handle()
    {
        parent::handle();
        $output = ob_get_clean();

        file_put_contents('error.log', $output); // or replace with DB insert
    }
}

then use it as handler

$whoops->pushHandler(new PrettyErrorLogger);

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda