If you are stuck with the cooperation between PHPStorm and xdebug on docker. trouble shooting

Aug 30, 2020 PHP xdebug

What is this

In case you want to link PHPStorm and xdebug on docker, “Why you can’t connect!” I will write a hint.

What is Xdebug?

Xdebug is a sophisticated PHP debugging tool. It makes it easy to see the familiar “var_dump” in PHP debugging, finds the bottom-necked process, and step through it. Another debugging tool is Zend Debugger. 5 Tips to use Xdebug | Let’s make a smartphone site application. Than.

Enable logging

Add settings to xdebug.ini and php.ini. After adding, you need to restart nginx and apache.


Since the log is displayed in /tmp/xdebug.log, Let’s identify the cause by looking at the content of the output error. If you google, related information will come out. Trying to communicate without looking at the logs is like entering a mountain without a map.

Is the xdebug setting loaded in the first place?

If xdebug does not work even if the setting of xdebug is described, and no log is output, Make sure that the settings are loaded in php. xdebug is not running due to forgetting to load xdebug.so, It is possible that the settings were overwritten in another file.

The following command outputs the setting values loaded in php. If xdebug is enabled, some xdebug related settings are printed.

php -r'phpinfo();' | grep xdebug

The part of | grep xdebug is narrowed down.

Is Path Mapping on PHPStorm set?

You need to set the mapping between the file path on docker and the file path on your local PC.

![Screenshot _2020-08-30_17_18_06.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/268801/05cd76a0-fef2-b3ee-2bfd-50a37d7efe94.(png)

set a breakpoint in index.php

Let’s put a breakpoint where it will be executed whenever it is accessed from the browser. If it is laravel, it is public/index.php. Now you can isolate the cause of whether xdebug is not working or where the breakpoint is added.

We hope you find this helpful.

#Reference https://qiita.com/haruna-nagayoshi/items/99fa041e884c2c3975d2 https://qiita.com/castaneai/items/d5fdf577a348012ed8af https://qiita.com/taniai-lvgs/items/8e9eba112d2d0ed2530f