在Intellij IDEA或者PhpStorm下用X-debug調試PHP

用Intellij IDEA或者PhpStorm使用X-debug來調試PHP,主要須要配置的部分有三個地方,分別爲php.ini的配置,IDEA的配置和瀏覽器的配置,主要以下,以備忘:php

  • php.ini的主要配置以下所示,關鍵參數根據實際狀況能夠修改:
    [Xdebug]
    zend_extension_ts=」X:/App/php-5.2.17-Win32-VC6-x86/ext/php_xdebug-2.1.1-5.2-vc6.dll」
    xdebug.remote_host=jichengdiaoding.com
    xdebug.remote_port = 9000
    xdebug.remote_mode = 「req」
    xdebug.remote_enable = on
    xdebug.remote_handler = dbgp
    xdebug.idekey = 「netbeans-xdebug」
    xdebug.profiler_enable=on
    xdebug.trace_output_dir=」X:/App/php-5.2.17-Win32-VC6-x86/xdebuginfo」
    xdebug.profiler_output_dir=」X:/App/php-5.2.17-Win32-VC6-x86/xdebuginfo」
    xdebug.auto_trace=on
    xdebug.collect_params=on
    xdebug.collect_return=on
    xdebug.show_exception_trace = On
    xdebug.remote_autostart = On
    xdebug.collect_vars = On配置好了,在CMD裏面輸入X:/App/php-5.2.17-Win32-VC6-x86/php.exe -m,若是能看到XDebug模塊,說明開啓成功。
    *: 值得注意的是,這裏須要肯定好XDebug和PHP的對應版本
  • IDEA的配置以下:
    進入File>Settings>PHP>Servers,這裏要填寫服務器端的相關信息,name填要調試的主機名 (如:jichengdiaoding.com或者localhost等),host填(如:localhost或者amiku.cn等),port填 80,debugger選XDebug

    進入File>Settings>PHP>Debug,看到XDebug選項卡,port填9000,其餘默認

    進入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 netbeans-xdebug,host 填jichengdiaoding.com,port 填80
  • 在Firefox或者Chrome瀏覽器中,找到對應的X-Debug版本的插件,以下爲Firefox下的調試插件:

    工具的設置裏的IDE KEY填上netbeans-xdebug,把jichengdiaoding.com加入到白名單,之後調試的時候把工具啓用就行了

    在IDEA中打開PHP的監聽,而後就能夠進入debug模式,方便的打斷點和查看變量以及監測等。
  •  配置完成。
相關文章
相關標籤/搜索