From 71d4b97c46398bd33440c17f9192f05493570847 Mon Sep 17 00:00:00 2001 From: dimti Date: Thu, 24 Nov 2022 18:27:36 +0300 Subject: [PATCH] + xdebug3 feature for php 8.1 --- bash/quit-xdebug.sh | 10 ++++++-- bash/start-xdebug.sh | 8 +++++- dockerfiles/php-fpm/xdebug3/xdebug.ini | 29 +++------------------- dockerfiles/php-fpm/xdebug3/xdebug.sh | 18 +++----------- src/.env | 1 - src/dockerfiles/php-fpm/php.base.Dockerfile | 3 --- src/dockerfiles/php-fpm/php.base56.Dockerfile | 3 --- src/dockerfiles/php-fpm/xdebug.ini | 25 ------------------- .../workspace/workspace.base.Dockerfile | 11 ++------ src/dockerfiles/workspace/workspace73.Dockerfile | 1 + src/dockerfiles/workspace/workspace74.Dockerfile | 1 + src/dockerfiles/workspace/workspace81.Dockerfile | 1 + src/dockerfiles/workspace/xdebug2.Dockerfile | 8 ++++++ src/dockerfiles/workspace/xdebug3.Dockerfile | 8 ++++++ src/dockerfiles/workspace/xdebug3.ini | 2 ++ 15 files changed, 45 insertions(+), 84 deletions(-) delete mode 100644 src/dockerfiles/php-fpm/xdebug.ini create mode 100644 src/dockerfiles/workspace/xdebug2.Dockerfile create mode 100644 src/dockerfiles/workspace/xdebug3.Dockerfile create mode 100644 src/dockerfiles/workspace/xdebug3.ini diff --git a/bash/quit-xdebug.sh b/bash/quit-xdebug.sh index 32dd4c9..45b9260 100755 --- a/bash/quit-xdebug.sh +++ b/bash/quit-xdebug.sh @@ -6,5 +6,11 @@ WITH_PROFILER=$2 if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi -${DIR}/dockerfiles/php-fpm/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER} -${DIR}/dockerfiles/workspace/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER} \ No newline at end of file +POSSIBLE_XDEBUG_VERSION=xdebug2 + +if [[ $PHP_VERSION -gt 81 ]]; then + POSSIBLE_XDEBUG_VERSION=xdebug3 +fi + +${DIR}/dockerfiles/php-fpm/${POSSIBLE_XDEBUG_VERSION}/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER} +${DIR}/dockerfiles/workspace/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER} diff --git a/bash/start-xdebug.sh b/bash/start-xdebug.sh index 1fb94c6..59d29c6 100755 --- a/bash/start-xdebug.sh +++ b/bash/start-xdebug.sh @@ -6,5 +6,11 @@ WITH_PROFILER=$2 if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi -${DIR}/dockerfiles/php-fpm/xdebug.sh start ${PHP_VERSION} ${WITH_PROFILER} +POSSIBLE_XDEBUG_VERSION=xdebug2 + +if [[ $PHP_VERSION -gt 81 ]]; then + POSSIBLE_XDEBUG_VERSION=xdebug3 +fi + +${DIR}/dockerfiles/php-fpm/${POSSIBLE_XDEBUG_VERSION}/xdebug.sh start ${PHP_VERSION} ${WITH_PROFILER} ${DIR}/dockerfiles/workspace/xdebug.sh start ${PHP_VERSION} ${WITH_PROFILER} diff --git a/dockerfiles/php-fpm/xdebug3/xdebug.ini b/dockerfiles/php-fpm/xdebug3/xdebug.ini index f90bbd7..58131ae 100644 --- a/dockerfiles/php-fpm/xdebug3/xdebug.ini +++ b/dockerfiles/php-fpm/xdebug3/xdebug.ini @@ -1,26 +1,3 @@ -; NOTE: The actual xdebug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini) - -;xdebug.remote_host=dockerhost -xdebug.remote_connect_back=1 -xdebug.remote_port=9000 -xdebug.idekey=PHPSTORM - -xdebug.remote_autostart=1 -xdebug.remote_enable=1 -xdebug.cli_color=0 -xdebug.profiler_enable=1 -xdebug.profiler_enable_trigger=1 -xdebug.profiler_output_dir=/tmp/profiler - -xdebug.remote_handler=dbgp -xdebug.remote_mode=req - -xdebug.var_display_max_children=-1 -xdebug.var_display_max_data=-1 -xdebug.var_display_max_depth=-1 - -xdebug.trace_enable_trigger=1 -xdebug.trace_output_dir=/tmp/trace -xdebug.trace_output_name="trace.%t" - -xdebug.show_exception_trace=1 \ No newline at end of file +xdebug.mode=off +xdebug.discover_client_host=1 +xdebug.start_with_request=yes diff --git a/dockerfiles/php-fpm/xdebug3/xdebug.sh b/dockerfiles/php-fpm/xdebug3/xdebug.sh index 1e1fcc4..f216fb5 100755 --- a/dockerfiles/php-fpm/xdebug3/xdebug.sh +++ b/dockerfiles/php-fpm/xdebug3/xdebug.sh @@ -31,16 +31,10 @@ xdebug_start () # And uncomment line with xdebug extension, thus enabling it ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" - REMOTE_AUTOSTART_CMD="sed -i 's/^xdebug.remote_autostart=0/xdebug.remote_autostart=1/g' /usr/local/etc/php/conf.d/xdebug.ini" - REMOTE_ENABLE_CMD="sed -i 's/^xdebug.remote_enable=0/xdebug.remote_enable=1/g' /usr/local/etc/php/conf.d/xdebug.ini" - PROFILER_ENABLE_CDM="sed -i 's/^xdebug.profiler_enable=0/xdebug.profiler_enable=1/g' /usr/local/etc/php/conf.d/xdebug.ini" + MODE_DEBUG_CMD="sed -i 's/^xdebug.mode.*/xdebug.mode=debug/g' /usr/local/etc/php/conf.d/xdebug.ini" docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}" - docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" - docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_ENABLE_CMD}" - if [[ ! -z "${WITH_PROFILER}" ]]; then - docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_ENABLE_CDM}" - fi + docker exec -it $PHP_FPM_CONTAINER bash -c "${MODE_DEBUG_CMD}" docker restart $PHP_FPM_CONTAINER docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' } @@ -52,14 +46,10 @@ xdebug_stop () # Comment out xdebug extension line OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" - REMOTE_AUTOSTART_CMD="sed -i 's/^xdebug.remote_autostart=1/xdebug.remote_autostart=0/g' /usr/local/etc/php/conf.d/xdebug.ini" - REMOTE_ENABLE_CMD="sed -i 's/^xdebug.remote_enable=1/xdebug.remote_enable=0/g' /usr/local/etc/php/conf.d/xdebug.ini" - PROFILER_DISABLE_CMD="sed -i 's/^xdebug.profiler_enable=1/xdebug.profiler_enable=0/g' /usr/local/etc/php/conf.d/xdebug.ini" + MODE_OFF_CMD="sed -i 's/^xdebug.mode.*/xdebug.mode=off/g' /usr/local/etc/php/conf.d/xdebug.ini" docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}" - docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" - docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_ENABLE_CMD}" - docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}" + docker exec -it $PHP_FPM_CONTAINER bash -c "${MODE_OFF_CMD}" # docker-compose restart php-fpm docker restart $PHP_FPM_CONTAINER docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' diff --git a/src/.env b/src/.env index 2d7bc82..858a263 100644 --- a/src/.env +++ b/src/.env @@ -7,7 +7,6 @@ WORKSPACE_INSTALL_MYSQL_CLIENT=true WORKSPACE_INSTALL_FSWATCH=false WORKSPACE_INSTALL_PING=true WORKSPACE_INSTALL_S3_MINIO_CLIENT=true -WORKSPACE_INSTALL_XDEBUG=true WORKSPACE_INSTALL_BZ2=true # PHP-extensions already installed: INTL, PGSQL, BCMATH WORKSPACE_INSTALL_WP_CLI=true diff --git a/src/dockerfiles/php-fpm/php.base.Dockerfile b/src/dockerfiles/php-fpm/php.base.Dockerfile index 9c7e4d1..78a5aa6 100644 --- a/src/dockerfiles/php-fpm/php.base.Dockerfile +++ b/src/dockerfiles/php-fpm/php.base.Dockerfile @@ -14,9 +14,6 @@ RUN apt-get update && docker-php-ext-install pdo pdo_mysql \ # xDebug: ########################################################################### -# Copy xdebug configuration for remote debugging -COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini - ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ diff --git a/src/dockerfiles/php-fpm/php.base56.Dockerfile b/src/dockerfiles/php-fpm/php.base56.Dockerfile index eacc778..3851c8f 100644 --- a/src/dockerfiles/php-fpm/php.base56.Dockerfile +++ b/src/dockerfiles/php-fpm/php.base56.Dockerfile @@ -14,9 +14,6 @@ RUN apt-get update && docker-php-ext-install pdo pdo_mysql \ # xDebug: ########################################################################### -# Copy xdebug configuration for remote debugging -COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini - ARG INSTALL_XDEBUG=false RUN if [ ${INSTALL_XDEBUG} = true ]; then \ diff --git a/src/dockerfiles/php-fpm/xdebug.ini b/src/dockerfiles/php-fpm/xdebug.ini deleted file mode 100644 index 3e66428..0000000 --- a/src/dockerfiles/php-fpm/xdebug.ini +++ /dev/null @@ -1,25 +0,0 @@ -; NOTE: The actual xdebug.so extension is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini) - -;xdebug.remote_host=dockerhost -xdebug.remote_connect_back=1 -xdebug.remote_port=9000 -xdebug.idekey=PHPSTORM - -xdebug.remote_autostart=1 -xdebug.remote_enable=1 -xdebug.cli_color=0 -xdebug.profiler_enable=1 -xdebug.profiler_enable_trigger=1 -xdebug.profiler_output_dir=/tmp - -xdebug.remote_handler=dbgp -xdebug.remote_mode=req - -xdebug.var_display_max_children=-1 -xdebug.var_display_max_data=-1 -xdebug.var_display_max_depth=-1 - -xdebug.trace_enable_trigger=1 -xdebug.trace_output_dir=/tmp -xdebug.trace_output_name="trace.%t" - diff --git a/src/dockerfiles/workspace/workspace.base.Dockerfile b/src/dockerfiles/workspace/workspace.base.Dockerfile index b1a7f26..0ef5c99 100644 --- a/src/dockerfiles/workspace/workspace.base.Dockerfile +++ b/src/dockerfiles/workspace/workspace.base.Dockerfile @@ -170,13 +170,7 @@ RUN if [ ${INSTALL_S3_MINIO_CLIENT} = true ]; then \ # xDebug: ########################################################################### -# Copy xdebug configuration for remote debugging -COPY ./xdebug.ini /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini - -ARG INSTALL_XDEBUG=false - -RUN if [ ${INSTALL_XDEBUG} = true ]; then \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ +RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \ pecl install xdebug-2.5.5; \ elif [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \ pecl install xdebug-3.1.6; \ @@ -184,8 +178,7 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ pecl install xdebug-2.9.8; \ fi && \ echo ';zend_extension=xdebug.so' > /etc/php/${PHP_VERSION}/cli/conf.d/20-xdebug.ini && \ - echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/vendor/bin/phpunit'" >> ~/.bashrc \ -;fi + echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/vendor/bin/phpunit'" >> ~/.bashrc ########################################################################### # BZ2: diff --git a/src/dockerfiles/workspace/workspace73.Dockerfile b/src/dockerfiles/workspace/workspace73.Dockerfile index 2c1b98e..a92c4c1 100644 --- a/src/dockerfiles/workspace/workspace73.Dockerfile +++ b/src/dockerfiles/workspace/workspace73.Dockerfile @@ -6,3 +6,4 @@ ENV PHP_VERSION ${PHP_VERSION} INCLUDE+ ./workspace.base.Dockerfile INCLUDE+ ./composer1.Dockerfile +INCLUDE+ ./xdebug2.Dockerfile diff --git a/src/dockerfiles/workspace/workspace74.Dockerfile b/src/dockerfiles/workspace/workspace74.Dockerfile index ec65ff8..84fe725 100644 --- a/src/dockerfiles/workspace/workspace74.Dockerfile +++ b/src/dockerfiles/workspace/workspace74.Dockerfile @@ -6,3 +6,4 @@ ENV PHP_VERSION ${PHP_VERSION} INCLUDE+ ./workspace.base.Dockerfile INCLUDE+ ./composer1.Dockerfile +INCLUDE+ ./xdebug2.Dockerfile diff --git a/src/dockerfiles/workspace/workspace81.Dockerfile b/src/dockerfiles/workspace/workspace81.Dockerfile index 38eb790..a7310d9 100644 --- a/src/dockerfiles/workspace/workspace81.Dockerfile +++ b/src/dockerfiles/workspace/workspace81.Dockerfile @@ -6,3 +6,4 @@ ENV PHP_VERSION ${PHP_VERSION} INCLUDE+ ./workspace.base.Dockerfile INCLUDE+ ./composer2.Dockerfile +INCLUDE+ ./xdebug3.Dockerfile diff --git a/src/dockerfiles/workspace/xdebug2.Dockerfile b/src/dockerfiles/workspace/xdebug2.Dockerfile new file mode 100644 index 0000000..ba547b2 --- /dev/null +++ b/src/dockerfiles/workspace/xdebug2.Dockerfile @@ -0,0 +1,8 @@ +########################################################################### +# xDebug: +########################################################################### + +USER root + +# Copy xdebug configuration for remote debugging +COPY ./xdebug2.ini /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini diff --git a/src/dockerfiles/workspace/xdebug3.Dockerfile b/src/dockerfiles/workspace/xdebug3.Dockerfile new file mode 100644 index 0000000..75aa4df --- /dev/null +++ b/src/dockerfiles/workspace/xdebug3.Dockerfile @@ -0,0 +1,8 @@ +########################################################################### +# xDebug: +########################################################################### + +USER root + +# Copy xdebug configuration for remote debugging +COPY ./xdebug3.ini /etc/php/${PHP_VERSION}/cli/conf.d/xdebug.ini diff --git a/src/dockerfiles/workspace/xdebug3.ini b/src/dockerfiles/workspace/xdebug3.ini new file mode 100644 index 0000000..d46739b --- /dev/null +++ b/src/dockerfiles/workspace/xdebug3.ini @@ -0,0 +1,2 @@ +xdebug.mode=debug +xdebug.start_with_request=yes