Skip to content

Instantly share code, notes, and snippets.

@patricknelson
Last active October 15, 2023 19:59
Show Gist options
  • Select an option

  • Save patricknelson/57ae24986cb13613314fb1f3c00a95d7 to your computer and use it in GitHub Desktop.

Select an option

Save patricknelson/57ae24986cb13613314fb1f3c00a95d7 to your computer and use it in GitHub Desktop.

Revisions

  1. patricknelson revised this gist Oct 18, 2021. 2 changed files with 22 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions xdebug.ini → xdebug.php5.ini
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ; For PHP 5.6 and Xdebug 2

    ; This file is intended to supplement the auto-generated "docker-php-ext-xdebug.ini" that gets created by the
    ; "docker-php-ext-enable xdebug" command. That ini file will contain the path to the dynamically built extension file
    ; (which is why they should remain separate).
    20 changes: 20 additions & 0 deletions xdebug.php7.ini
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    ; For PHP 7 and Xdebug 3

    ; This file is intended to supplement the auto-generated "docker-php-ext-xdebug.ini" that gets created by the
    ; "docker-php-ext-enable xdebug" command. That ini file will contain the path to the dynamically built extension file
    ; (which is why they should remain separate).

    [XDebug]
    ; General config
    ;xdebug.remote_enable = true ; Replaced by xdebug.mode=debug, see https://xdebug.org/docs/upgrade_guide and https://xdebug.org/docs/all_settings#mode
    xdebug.mode = debug
    xdebug.client_host = host.docker.internal
    xdebug.client_port = 9000

    ; Profiling (enable via cookie or GET/POST variable: XDEBUG_PROFILE=1).
    xdebug.profiler_enable = 0
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_dir = /tmp/xdebug-profiling/

    ; var_dump() settings.
    xdebug.cli_color = 1
  2. patricknelson revised this gist Mar 12, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion - Using Xdebug in Docker.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Getting setup and running with Xdebug in a docker container these days is now fa
    ```Dockerfile
    # Installing Xdebug with PHP 7.3 images:
    RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    && docker-php-ext-enable xdebug
    ```

    2. Ensure the `remote_host` is referencing `host.docker.internal` (Docker for Windows or Docker for Mac circa 18.03 and later, see docs: [Windows](https://docs.docker.com/docker-for-windows/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host) and [Mac](https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host)) or `10.0.2.2` for VirtualBox when using Docker Toolbox. For example, here's part of my `xdebug.ini`:
  3. patricknelson renamed this gist Sep 6, 2019. 1 changed file with 0 additions and 0 deletions.
  4. patricknelson renamed this gist Sep 6, 2019. 1 changed file with 0 additions and 0 deletions.
  5. patricknelson renamed this gist Sep 6, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. patricknelson revised this gist Sep 6, 2019. No changes.
  7. patricknelson revised this gist Sep 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -27,5 +27,5 @@ For more detailed example code, please see the files below!

    **Notes:**

    - These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php) at for PHP 7.3 and below. However: Starting with PHP 7.4, the `pecl` command will no longer be available. See: [Installing PHP extensions from source in your Dockerfile](https://olvlvl.com/2019-06-install-php-ext-source)
    - These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php) for PHP 7.3 and below. However, starting with PHP 7.4, the `pecl` command will no longer be available. See: [Installing PHP extensions from source in your Dockerfile](https://olvlvl.com/2019-06-install-php-ext-source)
    - For Alpine linux variants, ensure that you have also installed [phpize](https://www.php.net/manual/en/install.pecl.phpize.php) (necessary for building PHP extensions).
  8. patricknelson revised this gist Sep 6, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,5 @@ For more detailed example code, please see the files below!

    **Notes:**

    - These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php)
    - These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php) at for PHP 7.3 and below. However: Starting with PHP 7.4, the `pecl` command will no longer be available. See: [Installing PHP extensions from source in your Dockerfile](https://olvlvl.com/2019-06-install-php-ext-source)
    - For Alpine linux variants, ensure that you have also installed [phpize](https://www.php.net/manual/en/install.pecl.phpize.php) (necessary for building PHP extensions).
    - Starting with PHP 7.4, the `pecl` command will no longer be available. See: [Installing PHP extensions from source in your Dockerfile](https://olvlvl.com/2019-06-install-php-ext-source)
  9. patricknelson revised this gist Sep 6, 2019. 1 changed file with 10 additions and 2 deletions.
    12 changes: 10 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,9 @@

    Getting setup and running with Xdebug in a docker container these days is now fairly simple and is composed of two main steps:

    1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example with PHP 7.3 images:
    1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example:
    ```Dockerfile
    # Installing Xdebug with PHP 7.3 images:
    RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    ```
    @@ -21,4 +22,11 @@ Getting setup and running with Xdebug in a docker container these days is now fa
    ;xdebug.remote_host = 10.0.2.2
    ```

    **Note:** These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php), especially if you've ensured that you have also installed [phpize](https://www.php.net/manual/en/install.pecl.phpize.php) (necessary for building PHP extensions). For more detailed example code, please see the files below!
    For more detailed example code, please see the files below!


    **Notes:**

    - These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php)
    - For Alpine linux variants, ensure that you have also installed [phpize](https://www.php.net/manual/en/install.pecl.phpize.php) (necessary for building PHP extensions).
    - Starting with PHP 7.4, the `pecl` command will no longer be available. See: [Installing PHP extensions from source in your Dockerfile](https://olvlvl.com/2019-06-install-php-ext-source)
  10. patricknelson revised this gist Sep 6, 2019. 2 changed files with 5 additions and 5 deletions.
    8 changes: 4 additions & 4 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    FROM php:7-fpm-alpine
    FROM php:7.3-fpm-alpine

    # This example is extremely barebones and specific to Alpine linux, however in most containers
    # you can just run pecl + docker-php-ext-enable (see below) after you've ensured that you have
    # also installed phpize (necessary for building PHP extensions).
    # This example is extremely barebones and specific to Alpine linux, however in most containers at/below
    # php 7.3, you can just run pecl + docker-php-ext-enable (see below) after you've ensured that you have
    # also installed phpize (necessary for building PHP extensions).
    RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
    # Important part:
    && pecl install xdebug \
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    Getting setup and running with Xdebug in a docker container these days is now fairly simple and is composed of two main steps:

    1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example:
    1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example with PHP 7.3 images:
    ```Dockerfile
    RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
  11. patricknelson revised this gist Sep 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Dockerfile
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    FROM php:7-alpine
    FROM php:7-fpm-alpine

    # This example is extremely barebones and specific to Alpine linux, however in most containers
    # you can just run pecl + docker-php-ext-enable (see below) after you've ensured that you have
  12. patricknelson revised this gist Sep 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -21,4 +21,4 @@ Getting setup and running with Xdebug in a docker container these days is now fa
    ;xdebug.remote_host = 10.0.2.2
    ```

    **Note:** These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php), especially if you've ensured that you have also installed phpize (necessary for building PHP extensions). For more detailed example code, please see the files below!
    **Note:** These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php), especially if you've ensured that you have also installed [phpize](https://www.php.net/manual/en/install.pecl.phpize.php) (necessary for building PHP extensions). For more detailed example code, please see the files below!
  13. patricknelson revised this gist Sep 6, 2019. No changes.
  14. patricknelson revised this gist Sep 6, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,6 @@ Getting setup and running with Xdebug in a docker container these days is now fa
    RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    ```
    **Note:** This example is extremely generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php), especially if you've ensured that you have also installed phpize (necessary for building PHP extensions).

    2. Ensure the `remote_host` is referencing `host.docker.internal` (Docker for Windows or Docker for Mac circa 18.03 and later, see docs: [Windows](https://docs.docker.com/docker-for-windows/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host) and [Mac](https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host)) or `10.0.2.2` for VirtualBox when using Docker Toolbox. For example, here's part of my `xdebug.ini`:

    @@ -22,4 +21,4 @@ Getting setup and running with Xdebug in a docker container these days is now fa
    ;xdebug.remote_host = 10.0.2.2
    ```

    Note that these examples are highly simplified. See files below for more detailed example code.
    **Note:** These examples are very generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php), especially if you've ensured that you have also installed phpize (necessary for building PHP extensions). For more detailed example code, please see the files below!
  15. patricknelson revised this gist Sep 6, 2019. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions xdebug.ini
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    ; This file is intended to supplement the auto-generated "docker-php-ext-xdebug.ini" that gets created by the
    ; "docker-php-ext-enable xdebug" command. That ini file will contain the path to the dynamically built extension file
    ; (which is why they should remain separate).
    [XDebug]
    ; Allow remote hosts to enable debugging, in this case connecting back to the automatically maintained DNS
    ; name referencing our workstation: host.docker.internal
    xdebug.remote_enable = true
    xdebug.remote_host = host.docker.internal
    xdebug.remote_port = 9000
    xdebug.remote_handler = dbgp
    ; Profiling (enable via cookie or GET/POST variable: XDEBUG_PROFILE=1).
    xdebug.profiler_enable = 0
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_dir = /tmp/xdebug-profiling/
    ; var_dump() settings.
    xdebug.overload_var_dump = 1
    xdebug.cli_color = 1
    ; This file is intended to supplement the auto-generated "docker-php-ext-xdebug.ini" that gets created by the
    ; "docker-php-ext-enable xdebug" command. That ini file will contain the path to the dynamically built extension file
    ; (which is why they should remain separate).

    [XDebug]
    ; Allow remote hosts to enable debugging, in this case connecting back to the automatically maintained DNS
    ; name referencing our workstation: host.docker.internal
    xdebug.remote_enable = true
    xdebug.remote_host = host.docker.internal
    xdebug.remote_port = 9000
    xdebug.remote_handler = dbgp

    ; Profiling (enable via cookie or GET/POST variable: XDEBUG_PROFILE=1).
    xdebug.profiler_enable = 0
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_dir = /tmp/xdebug-profiling/

    ; var_dump() settings.
    xdebug.overload_var_dump = 1
    xdebug.cli_color = 1
  16. patricknelson created this gist Sep 6, 2019.
    15 changes: 15 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    FROM php:7-alpine

    # This example is extremely barebones and specific to Alpine linux, however in most containers
    # you can just run pecl + docker-php-ext-enable (see below) after you've ensured that you have
    # also installed phpize (necessary for building PHP extensions).
    RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS \
    # Important part:
    && pecl install xdebug \
    && docker-php-ext-enable xdebug \
    # Clean up...
    && apk del .phpize-deps

    # Copy over our custom xdebug INI configuration which will coexist with the automatically generated
    # $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini created by the "docker-php-ext-enable xdebug" command above.
    COPY ./xdebug.ini $PHP_INI_DIR/conf.d
    25 changes: 25 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Using Xdebug in Docker

    Getting setup and running with Xdebug in a docker container these days is now fairly simple and is composed of two main steps:

    1. Ensure you've got XDebug installed and enabled in your PHP docker image, for example:
    ```Dockerfile
    RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    ```
    **Note:** This example is extremely generic and should work in most of the [official PHP docker container images](https://hub.docker.com/_/php), especially if you've ensured that you have also installed phpize (necessary for building PHP extensions).

    2. Ensure the `remote_host` is referencing `host.docker.internal` (Docker for Windows or Docker for Mac circa 18.03 and later, see docs: [Windows](https://docs.docker.com/docker-for-windows/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host) and [Mac](https://docs.docker.com/docker-for-mac/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host)) or `10.0.2.2` for VirtualBox when using Docker Toolbox. For example, here's part of my `xdebug.ini`:

    ```ini
    ; Allow remote hosts to enable debugging, causing Xdebug to explicitly connect back to the workstation that Docker is running on.

    [XDebug]
    xdebug.remote_enable = true
    xdebug.remote_host = host.docker.internal

    ; Or, for workstations using Docker Toolbox (VirtualBox), use:
    ;xdebug.remote_host = 10.0.2.2
    ```

    Note that these examples are highly simplified. See files below for more detailed example code.
    20 changes: 20 additions & 0 deletions xdebug.ini
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    ; This file is intended to supplement the auto-generated "docker-php-ext-xdebug.ini" that gets created by the
    ; "docker-php-ext-enable xdebug" command. That ini file will contain the path to the dynamically built extension file
    ; (which is why they should remain separate).

    [XDebug]
    ; Allow remote hosts to enable debugging, in this case connecting back to the automatically maintained DNS
    ; name referencing our workstation: host.docker.internal
    xdebug.remote_enable = true
    xdebug.remote_host = host.docker.internal
    xdebug.remote_port = 9000
    xdebug.remote_handler = dbgp

    ; Profiling (enable via cookie or GET/POST variable: XDEBUG_PROFILE=1).
    xdebug.profiler_enable = 0
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_dir = /tmp/xdebug-profiling/

    ; var_dump() settings.
    xdebug.overload_var_dump = 1
    xdebug.cli_color = 1