If you get stuck with PHPStorm and xdebug on docker. trouble shooting

What is this

In the case where you want to link PHPStorm and xdebug on docker, "Why can't I connect ?!" I will write it as a hint.

What is Xdebug?

Xdebug is a powerful PHP debugging tool. It makes the familiar "var_dump" easier to see in PHP debugging, finds the bottom-necked process, and allows you to step through it. Another debugging tool is Zend Debugger. 5 tips to use Xdebug | Create a smartphone site app. Than.

Enable logging

Let's add settings to xdebug.ini and php.ini. After adding it, you need to restart nginx and apache.

xdebug.remote_log=/tmp/xdebug.log

The log will be displayed in /tmp/xdebug.log. Let's identify the cause by looking at the output error content. 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 you describe the xdebug settings, and there is no log Let's check if the settings are loaded in php. xdebug is not working because I forgot to load xdebug.so, It is possible that the settings were overwritten in another file.

The following command outputs the setting value loaded in php. If xdebug is enabled, some xdebug related settings will be output.

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

The part of | grep x debug is narrowed down.

Is Path Mapping set on PHPStorm?

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

スクリーンショット_2020-08-30_17_18_06.png

Set a breakpoint in index.php

Let's put a breakpoint where it always runs when accessed from a browser. In laravel, it is public / index.php. Now you can isolate the cause, whether xdebug isn't working or the breakpoint is added in the wrong place.

I 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

Recommended Posts

If you get stuck with PHPStorm and xdebug on docker. trouble shooting
If you have trouble uploading Wordpress image files with KUSANAGI Runs on Docker
If you are having trouble updating your Wordpress plugin with KUSANAGI Runs on Docker
symfony / http-kernel with phpstorm & docker phpunit & xdebug
If you have trouble with JPA or Hibernate, don't google and look here first
With podman in docker, everyone wants to get along and use docker on a shared computer
Until you run Quarkus and run docker image on Amazon ECS
Elasticsearch> Build with docker, get Twitter information and visualize with Kibana
Get started with DynamoDB with docker
Build Metabase with Docker on Lightsail and make it https with nginx
Until you put Ubuntu 20 on Windows 10 Home and WSL2 and run Docker
What to do if you get angry with OpenSSL with pyenv install
[Rails] What to do if you can't get parameters with form_with
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI