OwlyCode
6/16/2015 - 7:54 PM

Php error logging to stderr using Docker's official php:5.6-apache image

Php error logging to stderr using Docker's official php:5.6-apache image

<?php

use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\ExceptionHandler;

require_once __DIR__.'/vendor/autoload.php';

ErrorHandler::register();
$handler = ExceptionHandler::register(false);

$handler->setHandler(function (\Exception $e) {
    $output = fopen('php://stderr', 'w');
    fwrite($output, sprintf("%s\n%s\n", $e->getMessage(), $e->getTraceAsString()));
});

$app = require __DIR__ . '/app.php';

$app->run();