Skip to content

Instantly share code, notes, and snippets.

@OwlyCode
Created June 16, 2015 19:54
Show Gist options
  • Save OwlyCode/481ac04e13035ec6760d to your computer and use it in GitHub Desktop.
Save OwlyCode/481ac04e13035ec6760d to your computer and use it in GitHub Desktop.
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment