php.ini添加xdebug调试配置:

  1. // 推荐配置:
  2. zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
  3. xdebug.remote_enable = On
  4. xdebug.remote_handler = dbgp
  5. xdebug.remote_host= localhost
  6. xdebug.remote_port = 9002
  7. xdebug.idekey = PHPSTORM
  8. // 或使用如下配置:
  9. zend_extension="/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so"
  10. xdebug.remote_enable=1
  11. xdebug.remote_autostart=1
  12. xdebug.remote_connect_back=1
  13. xdebug.var_display_max_depth = 512
  14. xdebug.profiler_append = 1
  15. xdebug.profiler_enable_trigger = 1
  16. xdebug.max_nesting_level = 200
  17. xdebug.profiler_output_dir = "/Applications/MxSrvs/logs/xdebug"
  18. xdebug.profiler_output_name = "cachegrind.out.%t.%p"
  19. xdebug.remote_host=127.0.0.1
  20. xdebug.remote_port=9001
  21. xdebug.remote_handler = dbgp
  22. xdebug.idekey = PHPSTORM
  23. // xdebug3配置
  24. zend_extension="/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so"
  25. xdebug.mode = debug
  26. xdebug.start_with_request = yes
  27. xdebug.client_port = 9000
  28. xdebug.remote_host=127.0.0.1
  29. xdebug.remote_handler=dbgp
  30. xdebug.idekey=PHPSTORM

image.png

image.png
image.png

开启监听debug:
image.png

官方配置链接:https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html#configure-xdebug-wsl

  1. [xdebug]
  2. zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
  3. xdebug.start_with_request = yes
  4. # 使用WSL的IP地址 使用 cat /etc/resolv.conf 命令获取WSL的IP地址
  5. xdebug.client_host = 172.31.16.1
  6. xdebug.client_port = 9003
  7. xdebug.connect_timeout_ms = 200
  8. xdebug.discover_client_host = true
  9. xdebug.log = /tmp/xdebug.log
  10. xdebug.mode = debug
  11. xdebug.start_upon_error = yes
  12. xdebug.idekey = "PHPSTORM"
  13. xdebug.remote_handler = "dbgp"

1、Yii2框架出现强制断点在index.php第一行:Run -> Break at frist line in PHP script 取消勾选
2、断点在控制器中无效:修改settings -> Servers 映射目录,如果是wsl安装的Ubuntu子系统,修改Absolute path on server的映射目录为 /mnt/d/Demo/PHP/backendApi