PHP 利用xdebug单步调试

我们做开发的都知道单步调试必不可少,但是对于php来说不像其他语言一样方便单步调试,下面我就教大家怎么利用xdebug对php进行单步调试

一windows:

1.VSCode安装扩展PHP Debug.
2.安装XDebug.

3.1)假如没有用phpStudy软件需要设置php.ini

把php_xdebug-2.3.2-5.4-vc9-nts.dll拷贝到php/ext目录下。 (php_xdebug-2.3.2-5.4-vc9-nts.dll配置文件可以找我要)
然后再配置php.ini
zend_extension=ext/php_xdebug-2.3.2-5.4-vc9-nts.dll

[xdebug]
xdebug.remote_enable=1

   2).安装phpStudy的话,php_xdebug软件自带了,只需要配置php.inizend_extension=ext/php_xdebug-2.3.2-5.4-vc9-nts.dll


4.chrome安装扩展chromein.com_ext_11294文件拖到4.chrome扩展中,会自动安装。
5.配置Vscode.
按F1打开命令,输入setting选择用户设置。打开默认设置。配置可执行的php.exe文件
// Place your settings in this file to overwrite the default settings


{
    
 // 指向可执行的 php。
  
 "php.validate.executablePath": "C:/php54/php.exe"


}
5.launch.json
{
    "version": "0.2.0",
    
"configurations": 
[
       
{
            "name": "Listen for XDebug",
    
      "type": "php",
           
"request": "launch",
          
 "port": 9000
       
},
      
  {
            "name": "Launch currently open script",
      
     "type": "php",
          
 "request": "launch",
        
   "program": "${file}",
         
  "cwd": "${fileDirname}",
          
 "port": 9000
       
}
    
]
}
6.ctrl+shift+d打开调试。


终端php调试 set xdebug_config="idekey=1 remote_autostart=1"


二Mac:
找到php安装目录:
php -ini
which php
php —version
php —ini
whereis php
sudo vi /usr/local/etc/php/5.5/php.ini


1.安装brew 
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local —strip 1
2.跟新brew
sudo brew update
3.安装xdebug
sudo brew install homebrew/php/php55-xdebug


4.ext-xdebug.ini文件中配置
[xdebug]
zend_extension="/usr/local/opt/php55-xdebug/xdebug.so"


xdebug.remote_enable=1

5.setting:
配置php可执行文件:
"php.validate.executablePath": "/usr/local/bin/php"

brew search xdebug



技术链接:https://my.oschina.net/youdian/blog/753201

猜你喜欢

转载自blog.csdn.net/ywcsd/article/details/52701526