ubuntu中PHP xdebug 断点调试
Posted 贽殿遮那
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu中PHP xdebug 断点调试相关的知识,希望对你有一定的参考价值。
1.php.ini添加xdebug模块
1.1安装xdebug
sudo apt-get install php5.6-xdebug
1.2.查询扩展路径
find /etc/ -name "xdebug.ini"
一开始不带*精确查找不到,结果如下:
/etc/php/5.6/cli/conf.d/20-xdebug.ini
/etc/php/5.6/mods-available/xdebug.ini
/etc/php/5.6/apache2/conf.d/20-xdebug.ini
/etc/php/5.6/mods-available/xdebug.ini
/etc/php/5.6/apache2/conf.d/20-xdebug.ini
vi 在后面加上
xdebug.idekey=PHPSTORM
重启php或者apache2
/etc/init.d/apeach2 restart
最终效果在查看phpinfo页面
![](https://app.yinxiang.com/shard/s24/res/90135d9f-9459-4629-a3aa-89624d1934bf/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE.png)
2.phpstorm配置xdebug支持
php.ini 设置的远程端口 默认就是9000不用更改
![](https://app.yinxiang.com/shard/s24/res/afff5535-45f0-4efd-8ec7-9a3fcefa50dc/11.png)
phpstorm添加php serivers服务
![](https://app.yinxiang.com/shard/s24/res/fd304b90-755f-436e-b9d4-384e5ee0f70b/12.png)
DBGP proxy设置
![](https://app.yinxiang.com/shard/s24/res/62396853-5f2e-4378-9ac6-aae3b900cb81/13.png)
添加配置
![](https://app.yinxiang.com/shard/s24/res/6f9dad81-1511-49fe-b436-9049761c9b54/14.png)
![](https://app.yinxiang.com/shard/s24/res/24e7d0ad-afe4-4f11-b4e2-303fb795c76a/15.png)
![](https://app.yinxiang.com/shard/s24/res/774ecb57-21bb-48c7-b8c4-178b2e250338/16.png)
添加测试文件,设置断点
![](https://app.yinxiang.com/shard/s24/res/efc313b7-b892-41dd-8fa1-ef5d89d0426b/17.png)
postman 添加 cookie
![](https://app.yinxiang.com/shard/s24/res/f52149a5-d85a-4d56-8c91-1d95dd9362fc/18.png)
点击发送后我们的phpstorm会跳出刚才的debug页面
![](https://app.yinxiang.com/shard/s24/res/5b1609d6-c880-4755-b70a-577d02d1fc85/19.png)
![](https://app.yinxiang.com/shard/s24/res/5b1609d6-c880-4755-b70a-577d02d1fc85/19.png)
postman搭建xdebug并测试成功,下面介绍使用google chrome请求
安装 phpstorm helper 插件
安装debug插件
下载链接 phpstorm helper 插件 (https://www.crx4chrome.com/crx/768/)
安装 phpstorm helper 插件
安装debug插件
下载链接 phpstorm helper 插件 (https://www.crx4chrome.com/crx/768/)
![](https://app.yinxiang.com/shard/s24/res/0f7da9e9-5585-45a5-b709-38db9da34adf/20.png)
若直接拖动可以安装插件,不行我这有个方法改下载下来的文件后缀.crx改为.zip再拖动。
下载xdebug helper(https://www.crx4chrome.com/crx/1716/)
![](https://app.yinxiang.com/shard/s24/res/cf52eaf7-927b-45c1-91eb-e33d29f398d0/21.png)
安装成功的页面
![](https://app.yinxiang.com/shard/s24/res/f9f97033-7c53-48c9-a9da-d8970ea10e05/22.png)
右击debug图标,或者更多设置里点击选项按钮,设置ID key 上面是关闭的还要右键变成绿色。
可以输入地址www.webossgoo.com/index.php phpstorm那也触发了 但记得用完关闭
结尾来说说怎么测试:
![](https://app.yinxiang.com/shard/s24/res/9af3a9e0-33a3-4532-903b-fa13fe5ddfba/23.png)
第一个按钮:step over 步越
执行当前函数的下一步,如果有子函数,也不会进入,会一直执行到函数结束
第二个按钮:step into 步入
执行当前函数的下一步,如果有子函数,会从头到尾执行子函数,还原了程序执行的最详细的路线,从构造函数到结尾的每一步都会跳到。
第三个按钮:force step into
与step into 相同,执行当前函数的下一步,如果有子函数也会进入子函数,只不过不会从头到尾的还原函数执行的路线,会直接跳到子函数内第一步,构造函数等一些前置方法会忽略
第四个按钮:step out 步出
跳出当前执行的函数,跳到父函数的下一步。
第五个按钮:run to cursor
执行到下一个断点处
![](https://app.yinxiang.com/shard/s24/res/9af3a9e0-33a3-4532-903b-fa13fe5ddfba/23.png)
第一个按钮:step over 步越
执行当前函数的下一步,如果有子函数,也不会进入,会一直执行到函数结束
第二个按钮:step into 步入
执行当前函数的下一步,如果有子函数,会从头到尾执行子函数,还原了程序执行的最详细的路线,从构造函数到结尾的每一步都会跳到。
第三个按钮:force step into
与step into 相同,执行当前函数的下一步,如果有子函数也会进入子函数,只不过不会从头到尾的还原函数执行的路线,会直接跳到子函数内第一步,构造函数等一些前置方法会忽略
第四个按钮:step out 步出
跳出当前执行的函数,跳到父函数的下一步。
第五个按钮:run to cursor
执行到下一个断点处
以上是关于ubuntu中PHP xdebug 断点调试的主要内容,如果未能解决你的问题,请参考以下文章