Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pydawan/57b6f0c7411de6f583b780ca8dafa94d to your computer and use it in GitHub Desktop.
Save pydawan/57b6f0c7411de6f583b780ca8dafa94d to your computer and use it in GitHub Desktop.

Revisions

  1. Chris Taylor revised this gist Oct 17, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions vs-code-php-debug-docker-xdebug.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ RUN yes | pecl install xdebug \
    && echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini
    ```
    ## Bring up Docker container

    Run this shell script from the same folder as the Dockerfile
    <br>fire-up-docker.sh
    @@ -32,6 +33,7 @@ sudo docker run \
    -p 8080:80 \
    -d ctd/xdebug-tester:v1
    ```
    ## VS Code

    The php-debug extension configuration file in VS Code
    <br>launch.json
  2. Chris Taylor revised this gist Oct 17, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion vs-code-php-debug-docker-xdebug.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    Dockerfile
    ## The Dockerfile
    Only add the `xdebug.remote_log` line if you need to troubleshoot.

    ```
    FROM php:7.1-apache
  3. Chris Taylor created this gist Oct 17, 2018.
    53 changes: 53 additions & 0 deletions vs-code-php-debug-docker-xdebug.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    Dockerfile

    ```
    FROM php:7.1-apache
    RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_host=172.17.0.2" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_log=/var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/xdebug.ini
    ```

    Run this shell script from the same folder as the Dockerfile
    <br>fire-up-docker.sh
    ```
    # stop all containers
    sudo docker stop $(sudo docker ps -aq)
    # delete all containers
    sudo docker rm $(sudo docker ps -aq)
    sudo docker build -t ctd/xdebug-tester:v1 .
    sudo docker run \
    --detach \
    --name my-xdebug-tester \
    --volume=/home/chris/my-php-project:/var/www/html \
    -p 8080:80 \
    -d ctd/xdebug-tester:v1
    ```

    The php-debug extension configuration file in VS Code
    <br>launch.json
    ````
    {
    "version": "0.2.0",
    "configurations": [
    {
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9000,
    "log": true,
    "pathMappings": {
    "/var/www/html": "/home/chris/my-php-project"
    }
    }
    ]
    }
    ````