A fatal error is not an exception and cannot be caught. In 5.6 that includes calling a method on null and exhausting memory_limit — the request dies, the log gets a line, and any monitoring that relies on the application reporting its own failures sees nothing.
register_shutdown_function(function () {
$error = error_get_last();
if ($error && in_array($error['type'], [E_ERROR, E_PARSE, E_COMPILE_ERROR], true)) {
Log::critical('fatal', $error);
}
});
The shutdown function still runs after a fatal, which makes it the last place to record what happened. Keep it small: the memory that was exhausted is still exhausted, so anything that allocates is likely to fail. Reserving a block of memory at boot and freeing it here is the usual trick for making the log write succeed.