I'm having difficulty setting up a docker container with phpfpm to defer error handling to my php application.
Any fatal exceptions are being processed by the xdebug stack trace (http://xdebug.org/docs/stack_trace) as 200 OK, however I want to have the errors handled by the php handler (I want to restructure the error as json, and set response code to 500).
If I set display_errors = Off
in php.ini I get a code 500 which is good, but no error passed to the application layer (white screen of death).
For both cases above logging is working as intended.
To be clear, everything is functioning as normal (happy path is running fine) but when I intentionally cause a fatal error (It might happen in the future) I have issues.
How should I configure phpfpm/nginx to make sure the fatal errors are handled by the php application?
PHP-FPM config (dockerfile): https://github.com/nglume/docker-phpfpm/blob/master/Dockerfile
nginx config: https://github.com/nglume/docker-nginx/blob/master/config/nginx.conf
vhost: https://github.com/nglume/nglume/blob/master/vhosts/nginx/nglume-api.local.conf
Thanks!
Best Answer
Turns out the issue was a combination of phpfpm pool status
php_flag[display_errors]
was on and the lumen application did not have a registered handler forregister_shutdown_function
(it did have aset_error_handler
set).See https://laracasts.com/discuss/channels/lumen/lumen-debug-mode-not-showing-stack-trace for more info