Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write PHP errors to stderr?

How can I change php-fpm.conf (or php.ini) so all errors/ warnings/ ... are written to stderr (or alternatively to stdout)?

I run php5-fpm with daemonize = no and want to see all errors in my terminal.

like image 554
mattes Avatar asked Jul 06 '14 20:07

mattes


People also ask

How do I report errors in PHP?

Quickly Show All PHP Errors The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

Where does PHP stderr write to?

By default, whenever an error or exception is thrown, PHP sends the error message directly to the user via STDOUT. In a command-line environment, this means that errors are rendered in the terminal. In a web environment, errors and exceptions get displayed directly in the browser.

How can we trigger an error from within a PHP script?

Trigger an Error In PHP, this is done by the trigger_error() function.


1 Answers

The solution is to set ...

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = yes
like image 82
mattes Avatar answered Sep 28 '22 16:09

mattes