VS’s breakpoint debugging function is very powerful and can view all variables. PHP debugging is very troublesome, and writing echo and var_dump will make you want to vomit. Want to experience the pleasure of IDE debugging? Then let’s 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 the IDE receives the debugging information, it can xdebug sends single-step, abort, run and other commands. In this way, powerful debugging functions like vs can be achieved.
2. What you need: an IDE that supports xdebug remote debugging. Here we use phpstorm, which is a very powerful phpide. In addition, you need a version of xdebug corresponding to your php.
3. Step: Download xdebug first, please download the xdebug corresponding to your php version on the official website
If you don’t know your version, please echo phpinfo(); haha, and then copy the entire page to http ://xdebug.org/wizard.php in the box on this page, and then it will automatically analyze your php version, and then tell you which folder to put it in. We can just put it in the php expansion folder. I am D ; String, automatic remote debugging.
Then restart apache, and xdebug will be loaded successfully. The Shenma website will be much slower because you have enabled automatic remote debugging, and each visit will connect to the defined IP and port. Ha ha. It's up to you to decide.
Then it’s time to configure the IDE, select editconfig, and then configure it like this: Configure the server 127.0.0.1 80 xdebug in php remote debug, and then set the identification string. Here is the phpstorm4 we have defined and then save it. This is all configured. 4. Usage: Now we can start debugging. Click the button to start monitoring remote debugging. When it turns green, it means the monitoring is successful. Next we set a breakpoint. See Muyou, Youmuyouyoumuyou is very powerful and can be executed step by step. F7 single-steps into the function, and F8 is a single-step skip function. There are messages that I don’t understand.The above introduces the method of using phpstorm and xdebug to implement remote debugging, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.