xdebug是php调试的好帮手,sublime是php编写的好帮手。这里只说如何配置,默认读者会用sublime和xdebug 安装xdebug 在mac下非常方便: brew install php55-xdebug 然后进行配置,在 /usr/local/etc/php/5.5/conf.d/ext-xdebug.ini 中添加 xdebug.remote_enab
xdebug是php调试的好帮手,sublime是php编写的好帮手。这里只说如何配置,默认读者会用sublime和xdebug
在mac下非常方便:
brew install php55-xdebug
然后进行配置,在/usr/local/etc/php/5.5/conf.d/ext-xdebug.ini中添加
xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_log="/var/log/xdebug/xdebug.log"
重启apache
sudo apachectl restart
要调试某一个项目,首先得把这个项目在sublime下保存成一个project
sublime->project->save project as ...
然后用package control安装xdebug client
立即学习“PHP免费学习笔记(深入)”;
接下来配置项目
sublime->project->edit poject
配置文件类似以下内容:
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings": {
"xdebug": {
"url": "http://my.local.website/",
}
}
}
其中url是项目所在url,记得在hosts里头将这个url指向127.0.0.1,还有在apache的virtualhost里将其指向项目根目录
这样就OK了,准备开启调试吧
开启调试方式也比较简单,在想要加断点的地方右键
xdebug->Add/Remove breakpoint
这样项目在运行到本行的时候就会停止下来
然后开始调试,在菜单栏选择
tools->xdebug->start debugging(launch browser)
sublime会自动打开浏览器,进入配置时写的网站链接,进行调试
调试中所用的功能可以在调试文件中右键查看之
这可能是xdebug端口被占用,按Ctrl+`或者菜单栏View->show Console查看错误信息,有可能是xdebug端口已经被占用的缘故。
在sublime xdebug中关闭调试,或者重启sublime可以解决这个问题。
原文地址:用Xdebug和Sublime调试PHP代码, 感谢原作者分享。
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号