Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add xdebug3 support as separate image type #279

Merged
merged 3 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions commands/env-init.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions commands/env.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/xdebug.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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}"
}
Expand Down
1 change: 1 addition & 0 deletions docs/environments/initializing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environments/includes/php-fpm.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions images/php-fpm/context/xdebug3/etc/php-cli.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[php]
xdebug.client_host=${XDEBUG_REMOTE_HOST}
16 changes: 16 additions & 0 deletions images/php-fpm/context/xdebug3/etc/php.d/15-xdebug.ini
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions images/php-fpm/magento1/context/xdebug3/etc/php-cli.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[php]
xdebug.client_host=${XDEBUG_REMOTE_HOST}
16 changes: 16 additions & 0 deletions images/php-fpm/magento1/context/xdebug3/etc/php.d/15-xdebug.ini
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 13 additions & 0 deletions images/php-fpm/magento1/xdebug3/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions images/php-fpm/magento2/context/xdebug3/etc/php-cli.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[php]
xdebug.client_host=${XDEBUG_REMOTE_HOST}
16 changes: 16 additions & 0 deletions images/php-fpm/magento2/context/xdebug3/etc/php.d/15-xdebug.ini
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 13 additions & 0 deletions images/php-fpm/magento2/xdebug3/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions images/php-fpm/xdebug3/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions utils/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-}"
Expand Down