PhpStorm xdebug

preface

Debugging is unavoidable in the process of program development. In TERMS of PHP development, due to the scripting language nature, you should be sure and 100% sure to use breakpoint debugging in a manner similar to the following before using XDEBUG.

echo "";
die();
Copy the code

Like the way above is not not feasible, but do not feel too troublesome! We should be able to use assertion debugging on Eclipse as well as Java development. PHP, then, just happens to have an XDEBu feature for breakpoint debugging. If you don’t know what XDEBUG is, please come back to this article.


Environment introduction

* PHP version: 7.3.* XDEBUG version: 2.* PhpStorm version: 2020.2 Browser Xdebug plug-in: 1.6.1

Why use small leather panel? Because integration is easy to operate ah!! Why not use a higher version of xdebug3.0*? If you are interested, go to the xdebug website to download and play with it. Note that the parameters of php.ini have also been changed for your version of PHP

Xdebug works

Principle of single machine debugging

Principle of multi-machine debugging

Basically, by listening on the port, you tell the IDE that the request is a debug request, and then the IDE performs the debugging function, and you can interrupt the power to look at the data as you like


Debug setting

Phpstudy starts by creating a website (xxx.com), after selecting the appropriate PHP version, enable PHP xdebug.



Go to the appropriate php.ini to enable the following configuration
[Xdebug] zend_extension = D: / phpstudy_pro/Extensions/PHP/php7.3.4 NTS/ext/php_xdebug. DLL Xdebug. Collect_params = 1 xdebug.collect_return=1 xdebug.auto_trace=On Xdebug. Trace_output_dir = D: / phpstudy_pro/Extensions/php_log php7.3.4 NTS. Xdebug. Trace xdebug. Profiler_enable = On Xdebug. Profiler_output_dir = D: / phpstudy_pro/Extensions/php_log php7.3.4 NTS. Xdebug. Profilers xdebug. Remote_enable = 1; allow remote debug xdebug.remote_host=localhost xdebug.remote_port=9002; listen port xdebug.remote_handler=dbgp; default agreement xdebug.remote_log="D:\phpstudy_pro\Extensions\tmp\xdebug.log"Copy the code


Set the debug phpstorm

This is basically the end of the setup. Verification also passed, if not, please complete the Settings according to the IDE error message, and then do the actual demonstration effect


Do enough preliminary preparation for debugging

  1. Enable IDE Listening
  2. Enabling the Browser plug-in
  3. Break the code
  4. Select the PHP file to debug

Visit the site and launch the plug-in


The IDE sets breakpoints and enables listening


Debug successfully


conclusion

Eclipse is very convenient in comparison to Java’s breakpoint debugging. PhpStorm debugging requires a lot of plugins and configuration files, which requires a lot of upfront work. But let’s be PHPER, come on!