How can the php.ini setting be set conditionally depending on local operating system?
The .env file contains two variables:
XDEBUG_ENABLE=true
PHP_INI=./docker/runner/php.ini-development
Docker-compose.yml looks like this:
...
build:
context: .
dockerfile: ./docker/runner/Dockerfile
args:
- XDEBUG_ENABLE=${XDEBUG_ENABLE}
- PHP_INI=${PHP_INI}
...
The Dockerfile contains the following code:
...
ARG PHP_INI=./docker/runner/php.ini-local
COPY $PHP_INI /usr/local/etc/php/php.ini
ARG XDEBUG_ENABLE=false
RUN if [ $XDEBUG_ENABLE = true ]; then pecl install xdebug-2.6.0 && docker-php-ext-enable xdebug; fi;
...
The interesting thing is within the php.ini-development:
...
xdebug.default_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_host = docker.for.mac.host.internal
...
At this point there should be different setting for Apple and Linux machines, because Linux supports "xdebug.remote_connect_back = 1" and Apple doesn't.
I guess "uname" can be used and in case of response "Darwin" the settings can be used, otherwise they should be overwritten by "xdebug.remote_connect_back = 1".
How can I solve it?
EDIT: Currently I use an additional variable in the .env file like APPLE_OS_X=true. The Users have to adjust it to false when using Linux or Windows machines. Depending on this variable the value of xdebug.remote_connect_back will be overwritten with 1.
The question is still how I could react on the shell command 'uname' to automatically set the value of APPLE_OS_X in the .env file or xdebug.remote_connect_back in the Dockerfile.