xampp+phpStorm+Xdebug

来源:互联网 发布:东方卫视直播软件 编辑:程序博客网 时间:2024/04/30 12:53

朋友给推荐了phpStorm但安装之后觉得功能很强大,就试着去搞搞。

之前安装了appserver,但找到的资料写的是xampp,于是就下载了XAMPP,但不会用啊,Apache服务,mysql服务还有冲突,于是就找师兄帮忙。

先关闭了Appserver的apache服务和mysql服务。

将XAMPP的apache和mysql安装的服务卸掉,变成了X。(开机时候不会启动)然后start


  1. 服务器端(本地调试的情况下就是在本机)安装好XAMPP,停止apache服务(注意,如果直接退出XAMPP,是不会停止apache的)
  2. 在安装目录下找到php.ini,类似于D:\xampp\php\php.ini,并打开
  3. 找到被注释掉的项目并按如下设置:
      [XDebug]zend_extension = "D:\xampp\php\ext\php_xdebug.dll";xdebug.profiler_append = 0;xdebug.profiler_enable = 1;xdebug.profiler_enable_trigger = 0;xdebug.profiler_output_dir = "D:\xampp\tmp";xdebug.profiler_output_name = "cachegrind.out.%t-%s"xdebug.remote_enable = 1xdebug.remote_handler = "dbgp"xdebug.remote_host = "127.0.0.1";xdebug.trace_output_dir = "D:\xampp\tmp"xdebug.remote_mode = "req"xdebug.remote_port = 9000

    其中remote_host 是指调试客户端的地址,即IDE所在的IP,同理remote_port 是客户端的端口,这两项在远程调试的情况下注意修改

  4. 保存文件,打开apache,这时候在CMD里输入 D:\xampp\php\php.exe -m 看到XDebug,说明开启成功。至此,服务器端配置完毕
  5. 下面是客户端调试,打开phpStorm,进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,host填localhost,port填80,debugger选XDebug
  6. 进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认              
  7. 进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 phpStorm,host 填localhost,port 填80

  8. 点OK退出设置。


配置浏览器

Firefox浏览器可以安装 easy Xdebug ,Chrome上安装 Xdebug helper 。安装好后,在IDE Key 上填上 PHPSTORM (需要和配置一样)即可。

Firefox 下的 easy Xdebug 配置:

Firefox 下的 easy Xdebug 配置

Chrome 下的 Xdebug helper 配置:


Chrome 下的 Xdebug helper 配置

开始DEBUG

设置完成后,在PHPStorm里添加相应的断点,然后用刚配置好的浏览器访问相应页面,首次打开PHPStorm会提示是否接收来自PHP所在服务器的连接。如下图,Debugger窗口已经出现了调试信息:

  • 在phpStorm里打开监听(电话按钮)。
  • 在浏览器里打开XDebug工具,访问localhost,与phpStorm连接成功!


    PHPStorm Xdebug 显示
    PHPStorm Xdebug 显示

    When configuring the PHP interpreter for our project, PhpStorm will inform us if a debugger is installed and will yield the Xdebug or Zend Debugger version used.

    From the Settings | Project Settings | PHP | Servers window, we can validate our debugger setup using the Validate Remote Environmentbutton.

    This will open a new window where we can test the deployment environment on which we want to attach the debugger and validate the debugger configuration. This deployment environment can be “In place”, e.g. a local webserver or a remote server which is accessible by PhpStorm. Once we click Validate, PhpStorm will tell us if anything is missing (and what). Note that it can do that for both Xвebug and Zend Debugger.

    There we are! I missed xdebug.remote_enable again. If we select different options in PhpStorm from our deployment environment, Debugger Validation Configuration will detect that:

    If we’ve configured everything correctly, PhpStorm will be happy to tell:

    This new feature will save some time trying to figure out what is wrong with the debugger configuration. Give PhpStorm 7 EAP a try and as always, let us hear your thoughts in the issue tracker, through the comments below or in our forums!

  • 自己的配置

    安装参考链接:http://www.chenxuanyi.cn/xampp-phpstorm-xdebug.html

    http://www.cnblogs.com/xuxiang/p/3512560.html

    http://blog.csdn.net/meegomeego/article/details/25729205

    http://blog.jetbrains.com/phpstorm/2013/08/debugger-configuration-validation-with-phpstorm/

    http://solf.me/debug-php-with-xdebug-in-phpstorm/

    感谢!

  • 0 0
    原创粉丝点击