Endava/docker-php

Add display_errors to php.ini

Closed this issue · 2 comments

Can we add the following configs in php.ini and make it configurable via env vars?

  • display_errors
  • display_startup_errors

Default values for both is enabled which needs to be changed for production systems

$ php -i | grep display_errors
display_errors => STDOUT => STDOUT
$ php -i | grep display_startup_errors
display_startup_errors => On => On

I will make it configurable.

diff --git a/Dockerfile b/Dockerfile
index fade71a..c9720ca 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -181,6 +181,8 @@ ENV PHP_DATE_TIMEZONE="UTC" \
     PHP_XDEBUG_CLIENT_HOST='localhost' \
     PHP_XDEBUG_DISCOVER_CLIENT_HOST='false' \
     PHP_XDEBUG_IDEKEY='' \
+    PHP_DISPLAY_ERRORS='STDOUT' \
+    PHP_DISPLAY_STARTUP_ERRORS=1 \
     PHP_EXPOSE_PHP=1

 RUN mkdir -p /usr/src/app
diff --git a/files/php.ini b/files/php.ini
index bbee9c1..52af869 100644
--- a/files/php.ini
+++ b/files/php.ini
@@ -28,3 +28,5 @@ xdebug.idekey=${PHP_XDEBUG_IDEKEY}
 grpc.enable_fork_support=${PHP_GRPC_ENABLE_FORK_SUPPORT}
 grpc.poll_strategy=${PHP_GRPC_POLL_STRATEGY}
 expose_php=${PHP_EXPOSE_PHP}
+display_errors=${PHP_DISPLAY_ERRORS}
+display_startup_errors=${PHP_DISPLAY_STARTUP_ERRORS}

Added. Have fun!