phpstorm XDebug调试PHP

环境:

  • phpStudy 2016
  • phpstorm
  • Chrome

流程:

phpstudy

其他选项菜单->PHP扩展及设置->PHP扩展->Xdebug

其他选项菜单->打开配置文件->php-ini

修改自动生成的内容如下

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
[XDebug]
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir ="D:\phpstudy\tmp\xdebug"
xdebug.trace_output_dir ="D:\phpstudy\tmp\xdebug"
xdebug.profiler_output_name = "cache.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9001
xdebug.idekey = PHPSTORM
zend_extension="D:\phpstudy\php53\ext\xdebug.dll"

OK重启Apache

phpstorm

File->Setting->Language & Framworks->PHP

Servers 添加一个服务器

1
2
3
4
Name:localhost
Host:localhost
Port:80
Debugger:Xdebug

Debug->Xdebug

1
Debug port:9001 

Debug->DBGp Proxy

1
2
3
IDE Key:PHPSTORM
Host:127.0.0.1
Port:80

两种方法进行调试:

  1. Shift+F9
  • Chrome安装xdebug helper,并配置好
  • 点击界面右上角 Start Listening for PHP Debug Connections
  • 访问localhost

PS:

  • 如果发现基于MySQL的PHP程序异常慢, 请把代码中或程序配置中的localhost改为127.0.0.1
Licensed under CC BY-NC-SA 4.0
记录平时瞎折腾遇到的各种问题, 方便查找
使用 Hugo 构建
主题 Stack 3.29.0Jimmy 设计