PHP的学习--在sublime中使用XDebug(Ubuntu)
来源:互联网 发布:刷爱奇艺vip永久软件 编辑:程序博客网 时间:2024/05/16 19:28
说起来惭愧,自从开始使用Sublime Text之后,再也没有debug过PHP的代码,最近把debug的环境搭建了一下,在这里记录一下。
安装XDebug
sudo apt-get install php5-xdebug
编辑xdebug.ini文件,添加如下配置,可以先使用命令
whereis php5
来查找php5的位置,一般在/etc/php5/mods-available/目录下,找到xdebug.ini,输入以下内容:
xdebug.remote_enable=1xdebug.remote_handler=dbgpxdebug.remote_host=127.0.0.1xdebug.remote_port=9000xdebug.remote_log="/var/log/xdebug/xdebug.log"
其中参数代表的含义如下:
[Xdebug] ;load xdebug extensionzend_extension_ts = path/tp/xdebug;是否开启自动跟踪xdebug.auto_trace = On;是否开启异常跟踪xdebug.show_exception_trace = On;是否开启远程调试自动启动xdebug.remote_autostart = Off;是否开启远程调试xdebug.remote_enable = On;允许调试的客户端IPxdebug.remote_host=127.0.0.1;远程调试的端口(默认9000);xdebug.remote_port=9000;调试插件dbgpxdebug.remote_handler=dbgp;是否收集变量xdebug.collect_vars = On;是否收集返回值xdebug.collect_return = On;是否收集参数xdebug.collect_params = On;跟踪输出路径xdebug.trace_output_dir="path/to/xdebug/trace";是否开启调试内容xdebug.profiler_enable=On;调试输出路径xdebug.profiler_output_dir="path/to/xdebug/profiler"
重启nginx和php
sudo /etc/init.d/nginx restartsudo /etc/init.d/php-fpm restart
ps:这两个可以不操作,我的没有任何作用!
然后在Sublime Text使用package control安装xdebug client,
用ctrl+shift+p调出搜索框,输入Package Control: 选中其中的Package Control: Install Package,输入Xdebug client,找到xdebug client,安装,安装完成后要重启Sublime。其操作如下:
要调试某一个项目,首先得把这个项目在sublime下保存成一个project。
sublime->project->save project as ...
接下来配置项目
sublime->project->edit poject
配置文件类似以下内容:
{ "folders": [ { "follow_symlinks": true, "path": "." } ], "settings": { "xdebug": { "url": "http://my.local.website/", } }}
再在chrome中安装Chrome Xdebug Helper扩展。这个链接是本地下载的,不是链接到商店的!另外你还需要参考这里.
在下载和安装Chrome扩展后,你必须重新启动浏览器。重新启动后,你将看到在Chrome的地址栏的新图标:
点击它,将启用/禁用调试。但是,我们首先需要调整扩展中使用 Sublime Text 的会话密钥。
在Chrome中Tools > Extensions
打开Xdebug helper options:
开启调试方式也比较简单,在想要加断点的地方右键
xdebug->Add/Remove breakpoint
这样项目在运行到本行的时候就会停止下来
然后开始调试,在菜单栏选择
tools->xdebug->start debugging(launch browser)
sublime会自动打开浏览器,进入配置时写的网站链接,进行调试。
调试中所用的功能可以在调试文件中右键查看之。
快捷键说明如下
Start/Stop debugging session
- Start Debugging - Ctrl+Shift+F9 or ⌘+Shift+F9
- Start Debugging (Launch Browser)
- Restart Session
- Stop Debugging - Ctrl+Shift+F10 or ⌘+Shift+F10
- Stop Debugging (Launch Browser)
- Stop Debugging (Close Windows)
Breakpoints
- Add/Remove Breakpoint - Ctrl+F8 or ⌘+F8
- Set Conditional Breakpoint - Shift+F8
- Clear Breakpoints
- Clear All Breakpoints
Watch expressions
- Set Watch Expression
- Edit Watch Expression
- Remove Watch Expression
- Clear Watch Expressions
Session commands
- Evaluate
- Execute
- Status
Continuation commands
- Run - Ctrl+Shift+F5 or ⌘+Shift+F5
- Run To Line
- Step Over - Ctrl+Shift+F6 or ⌘+Shift+F6
- Step Into - Ctrl+Shift+F7 or ⌘+Shift+F7
- Step Out - Ctrl+Shift+F8 or ⌘+Shift+F8
- Stop
- Detach
Other
- Restore Layout / Close Windows - Ctrl+Shift+F11 or ⌘+Shift+F11
- Settings - Default
- Settings - User
问题无法跟踪断点
这可能是xdebug端口被占用,按Ctrl+`或者菜单栏View->show Console查看错误信息,有可能是xdebug端口已经被占用的缘故。
在sublime xdebug中关闭调试,或者重启sublime可以解决这个问题,如果还不行,可以修改端口号,如xdebug.ini中的端口号修改为为1000,在perferences->package settings->xdebug->setting-user文件中加入如下内容:
{ "port": 10000}
弄好这个还是费了些时间~~
- PHP的学习--在sublime中使用XDebug(Ubuntu)
- [PHP+xdebug] 在Ubuntu 14.04下的PhpStorm中配置xdebug调试环境
- [PHP+xdebug] 在Ubuntu 14.04下的PhpStorm中配置xdebug调试环境
- [PHP+xdebug] 在Ubuntu 14.04下的PhpStorm中配置xdebug调试环境
- sublime使用xdebug调试php
- sublime使用xdebug调试php
- sublime使用xdebug调试php
- PHP学习笔记 - 在Eclipse中使用XDebug调试代码 | Using XDebug debug code in eclipse
- PHP学习笔记 - 在Eclipse中使用XDebug调试代码 | Using XDebug debug code in eclipse
- PHP学习笔记 - 在Eclipse中使用XDebug调试代码 | Using XDebug debug code in eclipse
- 在osx中的sublime中安装php的xdebug调试器
- 转载 PHP学习笔记 - 在Eclipse中使用XDebug调试代码 | Using XDebug debug code in eclipse
- PHP Xdebug的使用
- sublime 安装 php xdebug
- XAMPP sublime Xdebug PHP
- sublime xdebug调试php
- 在vim中使用xdebug调试PHP程序
- 在PhpStorm中使用xdebug调试PHP代码
- Maximum Subarray -- Leetcode
- poj 1273 & hdu 1532 Drainage Ditches(最大流 )EK,dinic模板
- RVD (Rendezvous daemon)
- 黑马程序员-Java学习12-其它类
- ubuntu12.04安装压缩软件7z
- PHP的学习--在sublime中使用XDebug(Ubuntu)
- Android日程管理项目主要界面
- java解析XML的四种方式及比较
- Struts2的<s:if> 标签判断Action中的字段是否为null或者空字符串的方法
- 美好的回忆值得保留
- 还在使用findViewById()?教你如何注解式绑定控件
- [C++]LeetCode: 54 Best Time to Buy and Sell Stock
- linux 下查看cpu位数 内核等参数命令
- Java类库---Swing