PHPstorm + Xdebug 调试

1. 安装 PHP 之后一般不会默认安装 Xdebug,需要自己在 php.ini 中将相关扩展打开打开;

    下载正确的Xdebug文件(如果自行下载并配置后发现PHPinfo中始终没有xdebug时,考虑是下载版本不对)

    正确下载步骤:

    1. 复制phpinfo整个网页内容(Command+A),粘贴到https://xdebug.org/wizard.php 确定Xdebug版本(该网页会提示正确的版本及安装步骤)

    2. 根据需要在 php.ini 中配置相关项

[XDebug]
zend_extension = "D:\program\XAMPP7\php\ext\php_xdebug-2.6.0-7.1-vc14.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_name = "cache.out.%t-%s"
xdebug.remote_enable = true
xdebug.remote_mode = "req"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.collect_vars = On
xdebug.collect_return = On
xdebug.collect_params = On
xdebug.idekey="PHPSTORM"
xdebug.remote_autostart = 0
xdebug.trace_output_dir="../Projects/xdebug"
xdebug.profiler_output_dir="D:\program\XAMPP7\tmp"
xdebug.idekey="PHPSTORM"

2. PHPstorm 配置 server

     1、file -> settings -> Language&Frameworks -> php -> debug 中设置Xdebug port(务必与 php.ini 中配置一致);

    2、file -> settings -> Language&Frameworks -> php -> debug -> DBGp Proxy 配置

         (IDE key:与php.ini中一致,Host:localhost,Port:80);

    3、file -> settings -> Language&Frameworks -> php -> Servers 配置

          Name:自定义,Host:localhost,Port:80,Debugger:Xdebug

3. PHPstorm 设置运行配置 (Run -> Edit configurations)

    Name:自定义,Server:步骤2中配置的server,Start URL:从工程目录开始配置(如;/Shopping_platform_test/index.php/manager)

4. 测试

    点击PHPstorm 右上角 debug connections 和 debug 开始测试。

其他:

1. php_openssl 扩展

参看 https://blog.csdn.net/mrzhouxiaofei/article/details/66974625

猜你喜欢

转载自blog.csdn.net/beauty5188/article/details/80367371