Search code examples
laravelubuntuphpstormxdebuglaravel-sail

Run Xdebug on Laravel 8 with Sail & PhpStorm on Ubuntu


I have Ubuntu 18.04 and a fresh installation of Laravel 8. I want to use Xdebug together with Sail. I followed the instructions as follows:

  1. Added SAIL_XDEBUG_MODE=develop,debug to env
  2. Run sail build --no-cache and sail up -d
  3. Run docker inspect -f {{range.NetworkSettings.Networks}}{{.Gateway}}{{end}} <container-name> to get the IP of my docker container
  4. Added SAIL_XDEBUG_CONFIG="client_host=172.19.2.1" to env (IP from step 3)

Next I continued with the instruction from PhpStorm for debugging:

  1. Validated that Xdebug is active by sail php -v.
  2. Enabled listening to debug connection in PhpStorm
  3. Set a breakpoint and also enabled Break at first line in PHP scripts
  4. Installed Xdebug Helper browser extension for Chrome
  5. Clicked on debug in extension (bug is now green)
  6. Refresh page, page builds very slowly, but loads completely (which should not be the case, it should hang on a breakpoint)

If I switch to PhpStorm, then no dialog pops up. However, according to the instructions, there should be some instructions.

Reload the page in the browser and return to PhpStorm. In the Incoming Connection From dialog, select the path mappings so that PhpStorm can map the remote files on the web server to the local files in your project.

Hera are my debug settings: enter image description here

What am I missing?


Solution

  • Thanks to the helps of @LazyOne I got it working. I just had to skip step 3 & 4 in my instructions.

    Or in other words, I had to follow the instructions of https://laravel.com/docs/8.x/sail#debugging-with-xdebug but ignore the Linux Host IP Configuration section, although I am on Linux. Looks like this section is not appropriate for Ubuntu?