Guest User

Untitled

a guest
Aug 28th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. # Debug your PHP in Docker with Intellij/PHPStorm and Xdebug
  2.  
  3. 1. For your local dev, create a `Dockerfile` that is based on your production image and
  4. simply install `xdebug` into it. Exemple:
  5.  
  6. ```
  7. FROM php:5
  8.  
  9. RUN yes | pecl install xdebug \
  10. && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
  11. && echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
  12. && echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
  13. ```
  14. 2. Get you local IP address (`ifconfig` or such)
  15. 3. Start your container with the following environment variable: `XDEBUG_CONFIG="remote_host={{YOUR_IP_ADDRESS}}"`
  16. * Simple `docker` run: `docker run -e XDEBUG_CONFIG="remote_host={{YOUR_IP_ADDRESS}}" your-image`
  17. * With `docker-compose`:
  18.  
  19. ```yaml
  20. # docker-compose.yml
  21. foo:
  22. build: path/to/Dockerfile
  23. environment:
  24. XDEBUG_CONFIG: remote_host={{YOUR_IP_ADDRESS}}
  25. ```
  26. 4. In Intellij/PHPStorm go to: `Languages & Frameworks` > `PHP` > `Debug` > `DBGp Proxy` and set the following settings:
  27. * `Host`: your IP address
  28. * `Port`: 9000
  29.  
  30. Then you're all set and can start listening for PHP Debug connections from your IDE. On the first run it will ask you to map
  31. your local directoryies to the `docker` directories, but after that nothing will be required anymore!
  32.  
  33. Happy debugging!
Add Comment
Please, Sign In to add comment