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

306
Visualizações
Default Configuration like outputBuffering, displayErrorDetails not working in slim 3 php framework

I am using slim version 3.8 and I want to disable outputBuffering and show all errors: Following is my simple Hello World program.

require_once(dir.'/vendor/autoload.php');

$configuration = [
    'settings' => [
        'displayErrorDetails' => true,
        'outputBuffering' => false,
    ],
];

$app = new \Slim\App($configuration);

// Add route callbacks
$app->get('/', function ($request, $response, $args) {
    echo "here";
    return $response->withStatus(200)->write('Hello World!');
});

// Run application
$app->run();

If I comment out echo "here"; then it works fine. But this code is throwing exception - 500 internal error saying that "Unexpected data in output buffer. Maybe you have characters before an opening". Can someone please tell me what's going wrong here?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It's working as intended. You need to add addContentLengthHeader => false to your settings key in $configuration.

Setting outputBuffering to false means that the response object doesn't know about any data you echo out. Therefore, when it comes to automatically add the content-length header, it notices a mis-match and you get the "Unexpected data in output buffer" error. Hence, you need to disable automatically setting the content-type header.

over 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