I was addicted to the setting of laradock + VSCode + xdebug

environment

laradock Docker for Windows 2.0.0.3 (31259) VSCode 1.33.1 xdebug 2.7.2 php 7.2

settings on the laradock side

Set to install xdebug in workspace and PHP (.env)

...
WORKSPACE_INSTALL_XDEBUG=true
...
PHP_FPM_INSTALL_XDEBUG=true
...

Modify the two xdebug.ini as below (/php-fmp/xdebug.ini) (/workspace/xdebug.ini) xdebug.remote_host In the case of windows, it worked with docker host, but in the case of mac, it seems that it will not work unless it is set differently because the network configuration of Docker is different. xdebug.remote_port The default 9000 can be used as long as it is not used by other apps.

xdebug.remote_host=dockerhost
xdebug.remote_connect_back=0
xdebug.remote_port=9002
...
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=1

If docker-compose up with this, the laradock side is ok

VS Code side settings

Install the extension PHP Debug

Create the following file in the laravel project opened in Vscode (/.vscode/launch.json) port is the value specified in xdebug.ini pathMappings is {remote document root}: {host document root}

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9002,
            "stopOnEntry": true,
            "pathMappings": {
                "/var/www": "${workspaceRoot}"
            }
        }
    ]
}

Firewall settings

You need to configure your firewall so that VS Code can communicate with Xdebug in Docker. For the time being, VS Code is set to allow communication on a private network. I try xdebug in Docker's workspace container, but I get the following error and cannot connect.

        I: Connecting to configured address/port: dockerhost:9002.

        E: Time-out connecting to client. :-(

After investigating various things, the network on which Docker is running is an unidentified network (public), so communication was blocked by the firewall. So you can connect by allowing VS Code to communicate over public networks, or by considering unidentified networks as private.

reference

https://qiita.com/hiro-tarosuke/items/adcc382ca98dfb89401b https://qiita.com/ditflame/items/bf4b5f412bf607c5c6d2#%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%8C%E3%83%9E%E3%82%A6%E3%83%B3%E3%83%88%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84

Recommended Posts

I was addicted to the setting of laradock + VSCode + xdebug
I was addicted to the API version min23 setting of registerTorchCallback
I was addicted to the record of the associated model
The story I was addicted to when setting up STS
I was addicted to the roll method
I was addicted to the Spring-Batch test
A memorandum because I was addicted to the setting of the Android project of IntelliJ IDEA
Recorded because I was addicted to the standard input of the Scanner class
[CircleCI] I was addicted to the automatic test of CircleCI (rails + mysql) [Memo]
A story that I was addicted to twice with the automatic startup setting of Tomcat 8 on CentOS 8
I was addicted to starting sbt
What I was addicted to when introducing the JNI library
I was addicted to setting default_url_options with Rails devise introduction
I was addicted to looping the Update statement on MyBatis
What I was addicted to with the Redmine REST API
I tried to build the environment of WSL2 + Docker + VSCode
The part I was addicted to in "Introduction to Ajax in Java Web Applications" of NetBeans
About the matter that I was addicted to how to use hashmap
I was addicted to rewriting to @SpringApplicationConfiguration-> @SpringBootTest
What I was addicted to when updating the PHP version of the development environment (Docker) from 7.2.11 to 7.4.x
A memo that was soberly addicted to the request of multipart / form-data
Memorandum: What I was addicted to when I hit the accounting freee API
[Rails] I was addicted to the nginx settings when using Action Cable.
A story I was addicted to when testing the API using MockMVC
I was addicted to a simple test of Jedis (Java-> Redis library)
Problems I was addicted to when building the digdag environment with docker
I was addicted to scrollview because I couldn't tap the variable size UIView
I was addicted to unit testing with the buffer operator in RxJava
I was addicted to using RXTX on Sierra
I want to output the day of the week
I want to var_dump the contents of the intent
I was addicted to installing Ruby/Tk on MacOS
I was addicted to not being able to connect to AWS-S3 from the Docker container
I was a little addicted to the S3 Checksum comparison, so I made a note.
I was swallowed by the darkness of the romaji, trying to convert my name to romaji
I tried to summarize the state transition of docker
I tried to reduce the capacity of Spring Boot
I want to display the name of the poster of the comment
GetXxxx of ResultSet was addicted to primitive type (Java)
[Android] How to get the setting language of the terminal
I want to be aware of the contents of variables!
I want to return the scroll position of UITableView!
What I fixed when updating to Spring Boot 1.5.12 ・ What I was addicted to
I tried to summarize the basics of kotlin and java
What I was addicted to while using rspec on rails
I want to expand the clickable part of the link_to method
[Swift] I tried to implement the function of the vending machine
How to change the setting value of Springboot Hikari CP
I tried to summarize the basic grammar of Ruby briefly
I was addicted to using Java's Stream API in Scala
I want to narrow down the display of docker ps
[Ruby] I want to reverse the order of the hash table
A story I was addicted to with implicit type conversion of ActiveRecord during unit testing
I want to temporarily disable the swipe gesture of UIPageViewController
802.1X authentication to the network of Bonding setting in CentOS7
Technical causes and countermeasures for the points I was addicted to with the first Android app & Kotlin
I want to know the Method of the Controller where the Exception was thrown in the ExceptionHandler of Spring Boot
[Circle CI] A story I was addicted to at Start Building
I tried to summarize what was asked at the site-java edition-
I want to understand the flow of Spring processing request parameters
I tried to build the environment of PlantUML Server with Docker