How does PhpStorm connect to php XDebug in the docker container for breakpoint debugging?
藏色散人
Release: 2021-03-01 15:54:08
forward
2288 people have browsed it
The following tutorial column will introduce to you how PhpStorm connects to php XDebug in the docker container for breakpoint debugging. I hope it will be helpful to friends in need!
PhpStorm connects to php XDebug in the docker container for breakpoint debugging
PhpStorm connects to XDebug in the container for breakpoint debugging
Although breakpoint debugging in PHP is not as convenient as in other languages, some of them do have their uses, such as when debugging data exceptions within a loop. When php and phpstorm are both installed in the same environment, it is not difficult to configure phpstorm's xdebug debugging, but if you use a docker container to place your php environment, the cooperation between them is not that simple and easy. Ok, let’s introduce how to connect phpstorm to php xdebug in the docker container
Please note that this method requires the docker container to be able to communicate with the host through the network, so it is not suitable for the docker container on the mac. (Mac's docker is implemented using Linux vm technology and cannot communicate with the local network by default, but it can also save the country through other methods, which will not be discussed here), but phpstorm on the mac can use this method to connect to the docker container on the remote Linux server. php xdebug in the docker container
Configure the php xdebug environment in the docker containerAfter installing the php-pecl-xdebug extension in the docker container, edit /etc/php.d/ *-xdebug.ini file (if there is no such file, you can also write it directly at the end of the php.ini file)
Set the xdebug.remote_enable parameter to 1
Set xdebug.remote_host The parameter is set to your host IP (if your phpstorm is installed on your host, otherwise it points to the IP of the machine where your phpstorm is located)
Set the xdebug.remote_port parameter to the port you want to use (the default is 9000)
Configure phpstorm
Open phpstorm settings: PhpStorm->Preferences(command,)
Configure languages & Frameworks->PHP ->The debug port of the xdebug item in the Debug page is the port set by xdebug in your container
Configure languages & Frameworks->PHP->Servers page, add Server
Configure phpstorm's debug
Open phpstorm's settings: run->Edit configurations
Add a PHP Web Appliation
Set the icon of the small phone in the upper right corner In the listening state, you can enable the XDEBUG debugger
Browser extension
php's xdebug needs to monitor specific parameters in the request to enable xdebug debugging. It is recommended to install a browser extension here , the extension, when enabled, can save this parameter and append it to each page for debugging
Firefox browser can install: The easiest xdebug extension
Chrome browser can install: XDebug Helper extension
The above is the detailed content of How does PhpStorm connect to php XDebug in the docker container for breakpoint debugging?. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn