Home  >  Article  >  php教程  >  phpstorm xdebug remote debugging server PHP code

phpstorm xdebug remote debugging server PHP code

WBOY
WBOYOriginal
2016-07-06 13:34:261665browse

xdebug can debug the error code lines and error code details when a program error occurs. Let's take a look at a tutorial on phpstorm xdebug remote debugging server PHP code. The details are as follows.

How to debug local code with phpstorm xdebug, you should be familiar with the code. This article talks about how to debug the code of an online server. My PHP environment is lnmp1.2.

Install xdebug

Execute on the server


pecl install xdebug

The xdebug.so module will be installed.

Edit Configuration

Edit /usr/local/php/etc/php.ini and add the following code at the end:


[Xdebug]
zend_extension="xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=Your local public IP
xdebug.remote_port=9000
xdebug.remote_autostart=1

xdebug.idekey="PHPSTORM"

Execute in the terminal after the changes are completed

lnmp php-fpm reload

The server configuration ends here. Next, look at the IDE configuration.

Configure Server

Open Settings=>Languages ​​& Frameworks=>PHP=>Servers

The information in the red box is the information of the online server.

Configure DBGp Proxy

Open Settings=>Languages ​​& Frameworks=>PHP=>Debug=>DBGp Proxy

The red box needs to be consistent with the xdebug configuration file of the server.

Routing port mapping

Since most friend companies have routers, the local IP is the LAN IP, and the router’s port needs to be mapped locally. The specific rules are as follows:

Server Xdebug port => Local port. Here, the author maps the router's 9000 port to the local 9000 port.

Start debugging

Open the project's run configuration and select "PHP Web Application"

The author’s server here is https, so I added https. Readers, please fill in the URL according to the actual situation.

Click the "Phone" icon of the IDE to enable remote monitoring.

Open the code and breakpoint at the location shown in the picture

Click on the "Ladybug" icon,

Debugging can already be detected below the IDE.

<script>ec(2);</script>
Statement:
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