Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Xdebug on Devilbox with PhpStorm and Postman

Host OS

Tested on:

  • openSUSE 15.1 Leap
  • Fedora 30
  • Ubuntu 18.04.3 LTS

Check before setup:

  • Accept in the firewall the port 9000 TCP

Docker

(…setup without sudo…)

Check existance of the docker group

sudo groupadd docker

Add the current user to the docker group

sudo gpasswd -a $USER docker

Log out end log to again to accept the changes!

Test the permissions

docker run hello-world

Devilbox

(…for multisite setup see the Devilbox documentation…)

cd /_devilbox_install_dir_/cfg/php-ini-X.X/
cp devilbox-php.ini-xdebug xdebug.ini
nano xdebug.ini

Change these settings:

xdebug.default_enable  = 1
xdebug.profiler_enable = 1

xdebug.remote_enable       = 1
xdebug.remote_autostart    = 0
xdebug.remote_handler      = dbgp
xdebug.remote_port         = 9000
xdebug.remote_connect_back = 1

xdebug.idekey     = PHPSTORM
xdebug.remote_log = /var/log/php/xdebug.log

Save and restart DevilBox:

cd /_devilbox_install_dir_
docker-compose stop
docker-compose rm -f
docker-compose up -d 

… or when not everything is necessary:

docker-compose up httpd php mysql -d

"$ ERROR: for devilbox_bind_1 Cannot start service bind: (…) address already in use"

This error can occur when using docker-compose up -d with the bind container. The docs give the solution here - check /etc/resolv.conf to get your network manager.

PhpStorm

Settings / Languages & Frameworks / PHP

  • Set CLI Interpreter by clicking on
  • Add a new interpreter by clicking on + then choose From Docker, Vagr…
  • Tick Docker and add the Docker Server and then choose under Image name : devilbox/php-fpm:X.X-work…

Settings / Languages & Frameworks / PHP / Debug

Xdebug
    Debug port: 9000 ☑️ Can accept external connections
    ☑️ Force break at first line when no path mapping specified
    ☑️ Force break at first line when a script is outside the project

Settings / Languages & Frameworks / PHP / Debug / DBGp Proxy

IDE key: PHPSTORM
Host:    0.0.0.0
Port:    9000

Settings / Languages & Frameworks / PHP / Servers

  • Add a new server +
  • Set the Name of the server
  • Set values of Host to localhost : Port to 80
  • ☑️ Use path mappings (…)
File/Directory Absolute path on the server
/home/user/devel/htdocs /shared/httpd/devel/htdocs

Postman

Under Query Params set the key: XDEBUG_SESSION_START and the value PHPSTORM Click on the link Cookies (beneath the Send button) and add a new cookie for the corresponding domain:

XDEBUG_SESSION=PHPSTORM; path=/; domain=.yourlocaldomain.loc;
@dickprovoost

This comment has been minimized.

Copy link

commented Oct 3, 2019

Thanks a lot for this gist!! Especially the lines below where a blessing, could not find a better explanation elsewhere (my partner always says that i cannot find anything though) and it should have a more prominent place in the Devilbox docs:

Settings / Languages & Frameworks / PHP
Set CLI Interpreter by clicking on …
Add a new interpreter by clicking on + then choose From Docker, Vagr…
Tick Docker and add the Docker Server and then choose under Image name : devilbox/php-fpm:X.X-work…

I use Ubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.