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


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

  • 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模式,方便的打斷點和查看變量以及監測等。
  •  配置完成。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM