zoukankan      html  css  js  c++  java
  • 本地环境phpStorm10+XDebug配置和断点调试

     

    安装环境:XAMPP;phpStorm版本10; windows 7 64bit。

    XAMPP、phpStorm 都直接安装在了D盘根目录,9999m目录建在D:xampphtocts下,即目录工程文件夹路径为D:xampphtocts9999m。在phpStorm>File>open,找到9999m,点击确定,加载9999m到了phpStorm(安装环境路径根据需要自行更改,后面的配置内容也类似)。

     

    1.      开始服务器端配置:安装好XAMPP,停止apache服务(注意,如果直接退出XAMPP,是不会停止apache的)。

    2.      在安装目录下找到php.ini,类似于D:xamppphpphp.ini,并打开。

    3.      找到被注释掉的项目(去掉前面的?)并按如下设置:

    [XDebug]

    ==============原代码

    xdebug.profiler_append = 0
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 0
    xdebug.profiler_output_dir ="D:phpStudy mpxdebug"
    xdebug.trace_output_dir ="D:phpStudy mpxdebug"
    xdebug.profiler_output_name = "cache.out.%t-%s"
    xdebug.remote_enable = 1
    xdebug.remote_handler = "dbgp"
    xdebug.remote_host = "127.0.0.1"
    ;zend_extension="D:phpStudyphp53nextxdebug.dll"

    ==============改后

    xdebug.profiler_append = 0
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 0
    xdebug.profiler_output_dir ="D:phpStudy mpxdebug"
    xdebug.trace_output_dir ="D:phpStudy mpxdebug"
    xdebug.profiler_output_name = "cache.out.%t-%s"
    xdebug.remote_enable = 1
    xdebug.remote_handler = "dbgp"
    xdebug.remote_host = "127.0.0.1"
    zend_extension="D:phpStudyphp53nextxdebug.dll"
    xdebug.idekey= PHPSTROM

    ====================转载的

    zend_extension = "D:xamppphpextphp_xdebug.dll"

    xdebug.profiler_append = 0

    xdebug.profiler_enable = 1

    xdebug.profiler_enable_trigger = 0

    xdebug.profiler_output_dir = "D:xampp mp"

    xdebug.profiler_output_name = "cachegrind.out.%t-%s"

    xdebug.remote_enable = on

    xdebug.remote_handler = "dbgp"

    xdebug.remote_host = "127.0.0.1"

    xdebug.trace_output_dir = "D:xampp mp"

    xdebug.idekey= PHPSTROM   

     

    最初的设置是这样的:图2

     

    ;的意思是被注释掉了,所以要先去掉;号;

    然后开启xdebug.remote_enable = on;

    还要增加xdebug.idekey= PHPSTROM。

     

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

     

    [XDebug]

    zend_extension = "D:xamppphpextphp_xdebug.dll"

    xdebug.profiler_append = 0

    xdebug.profiler_enable = 1

    xdebug.profiler_enable_trigger = 0

    xdebug.profiler_output_dir = "D:xampp mp"

    xdebug.profiler_output_name = "cachegrind.out.%t-%s"

    xdebug.remote_enable = 1

    xdebug.remote_handler = "dbgp"

    xdebug.remote_mode = "req"

    xdebug.remote_port = 9000

     

    4.      保存文件,重新启动apache检查是否成功开启了xdebug服务。

     

     一种方法为在CMD里输入D:xamppphpphp.exe -m 看到XDebug,说明成功开启XDebug。

     

    另一种方法为浏览器打开localhost,找到phpinfo()点击打开配置情况,查找xdebug项,找到了说明xdebug配置成功。

     

    至此,服务器端配置完毕。

     

     

    5.      下面是客户端调试。打开phpStorm,进入File>Settings>PHP(文件-设置-语言和框架-php),这里要interpreter浏览,填D:xamppphpphp.exe,自动识别版本。

     

    6.      进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,

      ,host填localhost,port填80,debugger选XDebug。图7 是自定义的虚拟域名。

     

    7.      进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认。图8

     

     

    8.      进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 PHPSTORM,host 填localhost,port填9000,点OK退出设置。图9

     

     

    9.      进入Run> Debug configurations,点+号,Server选填localhost,start url 是在http://localhost的基础上再加上去,如加上 9999m,就形成http://localhost/9999m.

    以图中蓝色地址为参考, Browse 填chrome,点OK退出设置。图10

     

     

    点OK退出设置之后,phpstorm运行按钮旁边自动填充localhost,且运行按钮由灰色被激活成为绿色。如果start url填的是http://localhost,没有填写9999m,则当点击phpstorm运行按钮,浏览器进入默认地址http://localhost,没办法直接访问http://localhost/9999m

     

     

     

    10.   chrome浏览器链接配置。找到对应的插件,chrome的为phpstrom IDE Support chrome.crx,自己下载然后拖动文件到chrome设置>扩展程序。

     

      

    Chrome右上角增加了JB图标即为成功安装插件。

    11.   在phpStorm里打开监听,就是一个电话一样的按钮,点击变为绿色,在程序代码点前点击,设置程序段点,点击绿色的debug爬虫按钮,chrome浏览器打开xdebug页,phpStorm出现debug窗口,并获取到variables值,即为看到下面的debug信息,说明成功配置。图13

     

     

    12 断点调试

     

     通过点击红框中的位置设置和取消断点

     

     

     

     

    大功告成!!!

      参考文献:http://blog.sina.com.cn/zhyl4669 

  • 相关阅读:
    LeetCode 204
    华为OJ2051-最小的K个数(Top K问题)
    华为OJ1964-求解立方根(牛顿迭代法)
    华为OJ2288-合唱队(最长递增子序列)
    华为OJ2011-最长公共子串
    【Unix编程】进程间通信(IPC)
    可利用空间表(Free List)
    13.10 Scrapy 通用爬虫
    13.9 Scrapy 对接 Splash
    第十四章 分布式爬虫
  • 原文地址:https://www.cnblogs.com/xujian2016/p/5548921.html
Copyright © 2011-2022 走看看