VsCode 配置 PHP XDeBug

VsCode 配置 PHP XDeBug

九月 23, 2016 阅读 1673 字数 1592 评论 1 喜欢 1

学习PHP 你必须知道怎么配置php 的 XDebug

xdebug2016923172442

 

  • php.ini 配置

修改 PHP.ini ;

;XDEBUG
zend_extension = \"C:/php/ext/php_xdebug-2.4.0-7.0-vc14-nts-x86_64.dll\" 
[xdebug] 
;on or off as you are debuging local or remote 
;off means manualy run php.exe localy with the -dxdebug.remote_enable=1 parameter see \"launch.json\" below 
;on xdebug activate on server php all the time in debug mode. 

xdebug.remote_enable = off 
xdebug.remote_autostart = off xdebug.profiler_enable = off 
xdebug.profiler_enable_trigger = off 
xdebug.profiler_output_name = cachegrind.out.%t.%p 
xdebug.profiler_output_dir = \"c:/php/tmp\" 
xdebug.show_local_vars=0 
;dxdebug.remote_mode=req ;dxdebug.remote_port=9000 
;dxdebug.remote_host=127.0.0.1 
  •  修改VsCode 的调试的 launch.json 配置文件
修改vscode 的 launch.json 
{
 \"name\": \"Listen for PHP XDebug (remote mode)\",
 \"type\": \"php\",
 \"request\": \"launch\",
 \"port\": 9000 
}, 

{
 \"name\": \"PHP Debug current file (local mode)\",
 \"type\": \"php\",
 \"request\": \"launch\",
 \"program\": \"${file}\",
 \"runtimeArgs\": [\"-dxdebug.remote_enable=1\",\"-dxdebug.remote_autostart=1\",\"-dxdebug.remote_mode=req\",\"-dxdebug.remote_port=9000\",\"-dxdebug.remote_host=127.0.0.1\"],
 \"cwd\": \"${fileDirname}\",
 \"port\": 9000 
},

{
 \"name\": \"PHP Debugg application (start on myMain.php) (Local Mode).\",
 \"type\": \"php\",
 \"request\": \"launch\",
 \"program\": \"C:\\wwwPHP\\myMain.php\", \"runtimeArgs\": [\"-dxdebug.remote_enable=1\",\"-dxdebug.remote_autostart=1\",\"-dxdebug.remote_mode=req\",\"-dxdebug.remote_port=9000\",\"-dxdebug.remote_host=127.0.0.1\"],
 \"cwd\": \"C:\\wwwPHP\\\",
 \"port\": 9000 
}, 

{
 \"name\": \"Lounch PHP No Debug (Local mode).\",
 \"type\": \"php\",
 \"request\": \"launch\",
 \"program\": \"${file}\",
 \"cwd\": \"${fileDirname}\" 
}

 

注: 位置结合自己的位置修改