phpstore之xdebug配置

在开发中选好一款实用的开发工具。其实,对我们的开发效率至关重要。相信大家对sublime text非常熟悉,之前我一直都是使用这款编辑器,但因为这款编辑器对代码调试非常不方便,身为PHP轮子者,之前一直用var_dump等打印进行调试,这样调试起来效率非常低。本次跟大家分享的是用于PHP开发的一款PHPStorm(IDE)编辑器,我也是最近开始使用,更换编辑器的原因是它对debug非常方便。接下来就展示如何配置调试环境

确定xdebug是否安装
~ $ php -v
PHP 5.6.21 (cli) (built: Apr 29 2016 02:31:44) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

如果没有,安装xdebug

~ $ brew install php56-xdebug // mac上可以通过homebrew安装
//没有homebrew环境的,通过/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"这条命令安装
~ $ apt-get install php5-xdebug //ubuntu上安装指令
~ $ php -v //确认是否安装xdebug

xdebug配置

~ $ php --ini //找到配置文件
Configuration File (php.ini) Path: /usr/local/etc/php/5.6
Loaded Configuration File:         /usr/local/etc/php/5.6/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed:      /usr/local/etc/php/5.6/conf.d/ext-igbinary.ini,
/usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini,
/usr/local/etc/php/5.6/conf.d/ext-memcache.ini,
/usr/local/etc/php/5.6/conf.d/ext-redis.ini,
/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
~ $ vi /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini //编辑文件
//把下面内容加入ext-xdebug.ini文件
[xdebug]
  zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
  xdebug.remote_enable = on
  xdebug.remote_host = "localhost"
  xdebug.remote_port = 9000
  xdebug.remote_handler = "dbgp"
  xdebug.idekey = "phpstorm"
 //如果用到vagrant虚拟机上的PHP环境,则配置如下
   zend_extension=/usr/lib64/php/modules/xdebug.so
   xdebug.idekey = "vagrant"
   xdebug.remote_enable = 1
   xdebug.remote_port = 9000
   xdebug.remote_handler=dbgp
   xdebug.remote_log="/var/log/xdebug/xdebug.log"
   xdebug.remote_connect_back = on


OK,xdebug到此结束

phpStorm配置

phpstorm>Preferences如下图找PHP,点击PHP,设置PHP环境

这里写图片描述

展开上图中的Debug,选中DBGp Proxy,在红色标记2处设置Debug监听的host,端口,IDE key

这里写图片描述

接着就是设置Servers,选中Servers,点击新增,接着就是配置,操作及配置如下图

这里写图片描述

备注:如果是用到vagrant上的环境,则配置server的时候,就需要用到路径映射。在上面这个图中选中User path mapping之后会显示设置,设置如下图所示

这里写图片描述

configurations设置

这里写图片描述

新增PHP Web Application

这里写图片描述

浏览器xdebug插件配置

这里写图片描述

到这里整个环境就配置完成,接下来我们在代码中设置一个断点,在点击debug按钮,如果下图

这里写图片描述

这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值