PHPStorm下XDebug配置

 

1安装Xdebug

用yum安装可能会失败,用pecl安装成功。

#yum installphp-pecl-xdebug.x86_64

pecl installxdebug
         如果pecl命令不存在请先安装php-pear
         命令:yum install php-pear

注意多加了一项IDE Key,且要与后面PHPStorm中的配置相同:

zend_extension=/path/xdebug.so

zend_debugger.allow_hosts=10.25.1.199

zend_debugger.expose_remotely=always

zend_debugger.httpd_uid=-1

xdebug.auto_trace = on

xdebug.auto_profile = on

xdebug.collect_params = on

xdebug.collect_return = on

xdebug.profiler_enable = on

xdebug.trace_output_dir = "/tmp"

xdebug.profiler_output_dir ="/tmp"

xdebug.dump.GET = *

xdebug.dump.POST = *

xdebug.dump.COOKIE = *

xdebug.dump.SESSION = *

xdebug.var_display_max_data = 4056

xdebug.var_display_max_depth = 5

xdebug.remote_enable=on       

xdebug.remote_handler=dbgp

xdebug.remote_host=10.25.1.199

xdebug.remote_port=9010

xdebug.remote_autostart=1

xdebug.idekey="PHPSTORM"

 

2配置PHPStorm


图1:首先配置PHP解释器的路径

 


图2:File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,host填localhost,port填80,debugger选XDebug

 


图3:进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9010,其他默认

 


图4:进入File>Settings>PHP>Debug>DBGpProxy,IDE key填PHPSTORM,host填localhost,port 填80

 


图5:在phpStorm里打开监听,就是一个电话一样的按钮

 


图6:在浏览器里打开XDebug工具,访问localhost,与phpStorm连接成功!

 

3常见问题

访问页面准备进入断点时,PHPStorm报错:Cannot accept external Xdebug connection: Cannot evaluate expression'isset($_SERVER['PHP_IDE_CONFIG'])';

 

导致此问题的一个可能原因是:服务器端的php.ini中配置了:

         extension=/path/xdebug.so

应该只保留下面一个:

         zend_extension=/path/xdebug.so

 

参考资料

1 phpStorm+XDebug进行断点调试的配置

http://www.chenxuanyi.cn/xampp-phpstorm-xdebug.html

 

2利用下面网页中的Start debug按钮在COOKIE中设置Xdebug所需的变量。

http://www.jetbrains.com/phpstorm/marklets/

 

3 Cannot accept external Xdebug connection:Cannot evaluate expression 'isset($_SERVER['PHP_IDE_CONFIG'])

http://devnet.jetbrains.com/message/5463083?tstart=0

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
配置PhpStorm来使用Xdebug,可以按照以下步骤进行操作: 1. 首先,确保已经安装了PhpStorm,并且已经根据需要配置了PHP环境。 2. 下载Xdebug扩展。你可以从Xdebug官网(https://xdebug.org/download.php)下载最新的Xdebug版本。请注意,根据你的PHP版本(Thread Safe或Non-Thread Safe)选择正确的扩展版本。 3. 将下载的Xdebug扩展文件(通常是一个dll文件)复制到PHP的扩展目录下。你可以在php.ini文件中查找`extension_dir`指令,它指定了扩展目录的位置。 4. 打开php.ini文件,找到`zend_extension`指令,并将其设置为Xdebug扩展文件的路径。例如:`zend_extension = php_xdebug.dll`。 5. 在php.ini文件中添加以下Xdebug配置指令: ``` xdebug.remote_enable = On xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9100 ``` 6. 保存并关闭php.ini文件。 7. 在PhpStorm中打开项目,然后转到“File”菜单并选择“Settings”(或“Preferences”)。打开“Settings”(或“Preferences”)对话框。 8. 在对话框左侧导航栏中,选择“Languages & Frameworks” > “PHP” > “Debug”。 9. 在右侧窗格中,选择正确的PHP解释器。如果没有找到,请单击“…”按钮并添加一个新的解释器。 10. 在“Debug”选项卡下的“Xdebug”部分,确保已勾选“Debug”复选框,并检查选项卡中的其他配置。 11. 单击“OK”保存更改。 现在,你的PhpStorm已经配置好了使用Xdebug进行调试。你可以在需要调试的PHP代码行上设置断点,然后按下调试按钮来启动调试会话。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [最新phpStorm配置xdebug.docx](https://download.csdn.net/download/vhappy/12382317)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [PhpStorm配置Xdebug最完整最详解教程,100%成功!](https://blog.csdn.net/qq_34087545/article/details/89490269)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值