: This article describes how to use phpstorm and xdebug for remote debugging. if you are interested in the PHP Tutorial, refer to it. The breakpoint debugging function of vs is very powerful, and all variables can be viewed. Php debugging is very troublesome. you may have to say echo or var_dump. Would you like to experience the pleasure of ide debugging? Use xdebug.
1. principle: xdebug is a php debugging plug-in that supports remote debugging. when the php file is running, it can send debugging information to the remote port through the tcp protocol, when receiving the debugging information, ide can send xdebug commands such as One-Step running, stopping running, and running. In this way, powerful debugging functions such as vs are implemented.
2. what you need: an ide that supports remote debugging of xdebug. phpstorm is used here, which is a powerful phpide. In addition, you need an xdebug for your php version.
3. step: first download xdebug. please download the xdebug corresponding to your php version on the official website.
If you do not know your version, please echo phpinfo (); haha, then copy the entire page to the box on the page of the http://xdebug.org/wizard.php, then he will automatically analyze your php version, then, tell you which folder you want to put it in. we can just put it in the php Extension folder. I am D: \ xampp \ php \ ext.
Configure php. ini and add the following at the end:
[xdebug]zend_extension = D:\xampp\php\ext\php_xdebug-2.2.0-5.3-vc9.dllxdebug.remote_enable=1xdebug.remote_host=127.0.0.1xdebug.remote_port=9000xdebug.idekey=phpstorm4xdebug.remote_autostart=1
To explain, the first line is to load xdebug, and romote_enable is to enable remote debugging. below is the remote debugging parameters, ip addresses, ports, recognition strings, and automatic remote debugging.
Restart apache and load xdebug successfully. it will be much slower for Shenma website. because you have enabled automatic remote debugging, each access will connect to the defined ip address and port. Haha. Let's make a choice.
Then configure the ide,
Select editconfig and configure it as follows:
Configure the server 127.0.0.1 80 xdebug in php remote debug, and set the recognition string. Here we have defined phpstorm4 and saved it. In this way, the configuration is complete.
4. use: now we can start debugging.
Click to start remote debugging. if it turns green, the listener is successful. Next we will set a breakpoint.
We can see that there are wood, wood, and wood. it is very powerful. you can execute it step by step. F7 is a single-step function, and F8 is a single-step skip function. Leave a message that you do not understand.
The above describes how to use phpstorm and xdebug to implement remote debugging, including some content. if you are interested in the PHP Tutorial, you will be helpful.