php+xdebug remote debugging (single)

content

  1. Install and configure XDebug on the server
  2. Client PHPstorm Configuration
  3. Browser installation plugin

Install and configure XDebug on the server

XDebug installation

slightly

Configuration:

Open the php.ini configuration file:
vim /etc/php.ini

Add the following at the end:

[Xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host="客户端IP地址"
xdebug.remote_port="客户端开启的端口"

The port can be selected by yourself, for example, select port 5566.

After setting, restart the web service.

Note: This method does not support multi-person debugging, because remote_host can only fill in one IP address. If you need to allow other people in the team to debug, refer to: php+xdebug+dbgp remote debugging (multiple people)

Client PHPstorm Configuration

Set the port, make sure it is the same as the port number set in php.ini. If the port is not open, follow this link to open it.

Set up the server. Remember to first install FTP (eg vsftpd) on the server and configure it.
For example, it is assumed here that the xdebug user is created, and the account is used to log in to the machine 192.168.1.100.
Root path is set to the root directory of your project (assuming test here).

Still setting up the server, select the Mappings option. Just fill in a slash in the Deployment path on server column.

Start listening for debug:

Browser installation plugin

Here is an example of chrome.
Go to the chrome store, search for Xdebug helper, and install the plugin. Or click on the direct link: Xdebug helper

Restart your browser.

Right click on Xdebug helper on the chrome toolbar and select Options. Select PHPstorm in IDE key and click save on the right.

Debugging with breakpoints

Open PHPstorm and put breakpoints where you want to debug.

Go to the page you want to debug, left-click on Xdebug helper on the chrome toolbar, and select Debug.

Refresh the page or click the button to trigger the request, and once there is a line that executes to the breakpoint, it will stop. If it is the first time, PHPstorm will pop up a window.

Select Import mappings from deployment in Configure local file path, and select the server you just configured in Deployment.

Click Accept.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324813799&siteId=291194637