diff --git a/commands/env-init.cmd b/commands/env-init.cmd index 10e31782..e4a9a618 100644 --- a/commands/env-init.cmd +++ b/commands/env-init.cmd @@ -54,6 +54,7 @@ if [[ "${WARDEN_ENV_TYPE}" == "magento1" ]]; then MARIADB_VERSION=10.3 NODE_VERSION=10 PHP_VERSION=7.2 + PHP_XDEBUG_3=1 REDIS_VERSION=5.0 WARDEN_SELENIUM=0 @@ -80,6 +81,7 @@ if [[ "${WARDEN_ENV_TYPE}" == "magento2" ]]; then MARIADB_VERSION=10.3 NODE_VERSION=10 PHP_VERSION=7.4 + PHP_XDEBUG_3=1 RABBITMQ_VERSION=3.8 REDIS_VERSION=5.0 VARNISH_VERSION=6.0 @@ -108,6 +110,7 @@ if [[ "${WARDEN_ENV_TYPE}" == "laravel" ]]; then MARIADB_VERSION=10.4 NODE_VERSION=10 PHP_VERSION=7.4 + PHP_XDEBUG_3=1 REDIS_VERSION=5.0 WARDEN_DB=1 @@ -149,6 +152,7 @@ if [[ "${WARDEN_ENV_TYPE}" =~ ^symfony|shopware$ ]]; then MARIADB_VERSION=10.4 NODE_VERSION=10 PHP_VERSION=7.4 + PHP_XDEBUG_3=1 RABBITMQ_VERSION=3.8 REDIS_VERSION=5.0 VARNISH_VERSION=6.0 @@ -161,6 +165,7 @@ if [[ "${WARDEN_ENV_TYPE}" == "wordpress" ]]; then MARIADB_VERSION=10.4 NODE_VERSION=10 PHP_VERSION=7.4 + PHP_XDEBUG_3=1 WARDEN_DB=1 WARDEN_REDIS=0 diff --git a/commands/env.cmd b/commands/env.cmd index 01ad9e65..3053b1c2 100644 --- a/commands/env.cmd +++ b/commands/env.cmd @@ -17,6 +17,12 @@ if [[ ${WARDEN_ENV_TYPE} =~ ^magento ]]; then export WARDEN_SVC_PHP_VARIANT=-${WARDEN_ENV_TYPE} fi +## configure xdebug version +export XDEBUG_VERSION="debug" # xdebug2 image +if [[ ${PHP_XDEBUG_3} -eq 1 ]]; then + export XDEBUG_VERSION="xdebug3" +fi + if [[ ${WARDEN_ENV_TYPE} != local ]]; then WARDEN_NGINX=${WARDEN_NGINX:-1} WARDEN_DB=${WARDEN_DB:-1} diff --git a/docs/configuration/xdebug.md b/docs/configuration/xdebug.md index cca29de5..02274d59 100644 --- a/docs/configuration/xdebug.md +++ b/docs/configuration/xdebug.md @@ -1,8 +1,8 @@ ## Xdebug Support -There are two docker containers running FPM, `php-fpm` and `php-debug`. The `php-debug` container has the Xdebug extension pre-installed. Nginx will automatically route requests to the `php-debug` container when the `XDEBUG_SESSION` cookie has been set to `PHPSTORM` via the Xdebug Helper browser extension. +There are two docker containers running FPM, `php-fpm`, `php-debug`. The `php-debug` container has the **Xdebug** extension pre-installed. Nginx will automatically route requests to the `php-debug` container when the `XDEBUG_SESSION` cookie has been set to `PHPSTORM` via the Xdebug Helper browser extension. -Xdebug will automatically connect back to the host machine on port 9000 for each request routed to the `php-debug` container (i.e. when the `XDEBUG_SESSION` cookie is set). When configuring Xdebug Helper in your browser, make sure it is setting this cookie with the value `PHPSTORM`. +Xdebug will automatically connect back to the host machine on port `9000` for `xdebug2` and `9003` for `xdebug3` for each request routed to the `php-debug` container (i.e. when the `XDEBUG_SESSION` cookie is set). When configuring Xdebug Helper in your browser, make sure it is setting this cookie with the value `PHPSTORM`. In similar fashion to the `warden shell` command there is also a debug command to launch into an xdebug enabled container shell for debugging CLI workflows: @@ -22,7 +22,7 @@ To configure a project in VSCode for debugging, add the following to `.vscode/la "name": "Listen for XDebug", "type": "php", "request": "launch", - "port": 9000, + "port": 9003, "pathMappings": { "/var/www/html": "${workspaceRoot}" } diff --git a/docs/environments/initializing.md b/docs/environments/initializing.md index 1d393f9f..229605c3 100644 --- a/docs/environments/initializing.md +++ b/docs/environments/initializing.md @@ -36,6 +36,7 @@ The below example demonstrates the from-scratch setup of the Magento 2 applicati MARIADB_VERSION=10.3 NODE_VERSION=10 PHP_VERSION=7.3 + PHP_XDEBUG_3=1 RABBITMQ_VERSION=3.8 REDIS_VERSION=5.0 VARNISH_VERSION=6.0 diff --git a/environments/includes/php-fpm.base.yml b/environments/includes/php-fpm.base.yml index c12f7b70..648a8e2a 100644 --- a/environments/includes/php-fpm.base.yml +++ b/environments/includes/php-fpm.base.yml @@ -28,7 +28,7 @@ services: php-debug: hostname: "${WARDEN_ENV_NAME}-php-debug" - image: docker.io/wardenenv/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-}-debug + image: docker.io/wardenenv/php-fpm:${PHP_VERSION:-7.4}${WARDEN_SVC_PHP_VARIANT:-}-${XDEBUG_VERSION:-debug} environment: - TRAEFIK_DOMAIN - TRAEFIK_SUBDOMAIN diff --git a/images/php-fpm/context/xdebug3/etc/php-cli.ini b/images/php-fpm/context/xdebug3/etc/php-cli.ini new file mode 100644 index 00000000..715cf622 --- /dev/null +++ b/images/php-fpm/context/xdebug3/etc/php-cli.ini @@ -0,0 +1,2 @@ +[php] +xdebug.client_host=${XDEBUG_REMOTE_HOST} diff --git a/images/php-fpm/context/xdebug3/etc/php.d/15-xdebug.ini b/images/php-fpm/context/xdebug3/etc/php.d/15-xdebug.ini new file mode 100644 index 00000000..c827611c --- /dev/null +++ b/images/php-fpm/context/xdebug3/etc/php.d/15-xdebug.ini @@ -0,0 +1,16 @@ +; Enable xdebug extension module +zend_extension=xdebug.so + +xdebug.discover_client_host="on" +xdebug.client_discovery_header="HTTP_X_DEBUG_HOST" +xdebug.idekey="PHPSTORM" +xdebug.show_local_vars="on" +xdebug.var_display_max_depth=3 +xdebug.max_nesting_level=250 +xdebug.file_link_format = '"phpstorm://open?file=%f&line=%l"' + +xdebug.mode=debug,trace,profile +xdebug.start_with_request=trigger +xdebug.output_dir="/tmp" +xdebug.profiler_output_name="cachegrind.out.%t.%s_%R" +xdebug.trace_output_name="trace.%t.%s_%R" diff --git a/images/php-fpm/magento1/context/xdebug3/etc/php-cli.ini b/images/php-fpm/magento1/context/xdebug3/etc/php-cli.ini new file mode 100644 index 00000000..715cf622 --- /dev/null +++ b/images/php-fpm/magento1/context/xdebug3/etc/php-cli.ini @@ -0,0 +1,2 @@ +[php] +xdebug.client_host=${XDEBUG_REMOTE_HOST} diff --git a/images/php-fpm/magento1/context/xdebug3/etc/php.d/15-xdebug.ini b/images/php-fpm/magento1/context/xdebug3/etc/php.d/15-xdebug.ini new file mode 100644 index 00000000..c827611c --- /dev/null +++ b/images/php-fpm/magento1/context/xdebug3/etc/php.d/15-xdebug.ini @@ -0,0 +1,16 @@ +; Enable xdebug extension module +zend_extension=xdebug.so + +xdebug.discover_client_host="on" +xdebug.client_discovery_header="HTTP_X_DEBUG_HOST" +xdebug.idekey="PHPSTORM" +xdebug.show_local_vars="on" +xdebug.var_display_max_depth=3 +xdebug.max_nesting_level=250 +xdebug.file_link_format = '"phpstorm://open?file=%f&line=%l"' + +xdebug.mode=debug,trace,profile +xdebug.start_with_request=trigger +xdebug.output_dir="/tmp" +xdebug.profiler_output_name="cachegrind.out.%t.%s_%R" +xdebug.trace_output_name="trace.%t.%s_%R" diff --git a/images/php-fpm/magento1/xdebug3/Dockerfile b/images/php-fpm/magento1/xdebug3/Dockerfile new file mode 100644 index 00000000..4adbd8e6 --- /dev/null +++ b/images/php-fpm/magento1/xdebug3/Dockerfile @@ -0,0 +1,13 @@ +ARG PHP_VERSION= +FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +USER root + +RUN set -eux \ + && yum install -y php-pecl-xdebug3 \ + && yum clean all \ + && rm -rf /var/cache/yum + +COPY xdebug3/etc/*.ini /etc/ +COPY xdebug3/etc/php.d/*.ini /etc/php.d/ + +USER www-data diff --git a/images/php-fpm/magento2/context/xdebug3/etc/php-cli.ini b/images/php-fpm/magento2/context/xdebug3/etc/php-cli.ini new file mode 100644 index 00000000..715cf622 --- /dev/null +++ b/images/php-fpm/magento2/context/xdebug3/etc/php-cli.ini @@ -0,0 +1,2 @@ +[php] +xdebug.client_host=${XDEBUG_REMOTE_HOST} diff --git a/images/php-fpm/magento2/context/xdebug3/etc/php.d/15-xdebug.ini b/images/php-fpm/magento2/context/xdebug3/etc/php.d/15-xdebug.ini new file mode 100644 index 00000000..c827611c --- /dev/null +++ b/images/php-fpm/magento2/context/xdebug3/etc/php.d/15-xdebug.ini @@ -0,0 +1,16 @@ +; Enable xdebug extension module +zend_extension=xdebug.so + +xdebug.discover_client_host="on" +xdebug.client_discovery_header="HTTP_X_DEBUG_HOST" +xdebug.idekey="PHPSTORM" +xdebug.show_local_vars="on" +xdebug.var_display_max_depth=3 +xdebug.max_nesting_level=250 +xdebug.file_link_format = '"phpstorm://open?file=%f&line=%l"' + +xdebug.mode=debug,trace,profile +xdebug.start_with_request=trigger +xdebug.output_dir="/tmp" +xdebug.profiler_output_name="cachegrind.out.%t.%s_%R" +xdebug.trace_output_name="trace.%t.%s_%R" diff --git a/images/php-fpm/magento2/xdebug3/Dockerfile b/images/php-fpm/magento2/xdebug3/Dockerfile new file mode 100644 index 00000000..4adbd8e6 --- /dev/null +++ b/images/php-fpm/magento2/xdebug3/Dockerfile @@ -0,0 +1,13 @@ +ARG PHP_VERSION= +FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +USER root + +RUN set -eux \ + && yum install -y php-pecl-xdebug3 \ + && yum clean all \ + && rm -rf /var/cache/yum + +COPY xdebug3/etc/*.ini /etc/ +COPY xdebug3/etc/php.d/*.ini /etc/php.d/ + +USER www-data diff --git a/images/php-fpm/xdebug3/Dockerfile b/images/php-fpm/xdebug3/Dockerfile new file mode 100644 index 00000000..4adbd8e6 --- /dev/null +++ b/images/php-fpm/xdebug3/Dockerfile @@ -0,0 +1,13 @@ +ARG PHP_VERSION= +FROM docker.io/wardenenv/php-fpm:${PHP_VERSION} +USER root + +RUN set -eux \ + && yum install -y php-pecl-xdebug3 \ + && yum clean all \ + && rm -rf /var/cache/yum + +COPY xdebug3/etc/*.ini /etc/ +COPY xdebug3/etc/php.d/*.ini /etc/php.d/ + +USER www-data diff --git a/utils/env.sh b/utils/env.sh index 07f29638..80b6d86d 100644 --- a/utils/env.sh +++ b/utils/env.sh @@ -35,6 +35,7 @@ function loadEnvConfig () { local WARDEN_ENV_PATH="${1}" eval "$(grep "^WARDEN_" "${WARDEN_ENV_PATH}/.env")" eval "$(grep "^TRAEFIK_" "${WARDEN_ENV_PATH}/.env")" + eval "$(grep "^PHP_" "${WARDEN_ENV_PATH}/.env")" WARDEN_ENV_NAME="${WARDEN_ENV_NAME:-}" WARDEN_ENV_TYPE="${WARDEN_ENV_TYPE:-}"