mac環境下支持PHP調試工具xdebug,phpstorm監聽


剛開始配置xdebug花了不少時間,記錄下來,希望可以幫到你吧
 
大概思路:
  1.從xdebug官網下載相應的解壓包
  2.編譯到PHP擴展里
如果不用phpstorm監聽,上述兩個步驟就已經夠支持了。
  3.修改php.ini配置phpstorm監聽的端口號等信息
  4.配置phpstorm的監聽的server和端口號
 
先讓php支持xdebug
方式一
https://xdebug.org/download.php 下載相應的xdebug 
可以到 http://xdebug.org/wizard.php 把phpinfo的所有信息粘貼上去,會給出相應的版本
解壓 tar -zxvf xdebug 
cd xdebug目錄下
執行 phpize(我的目錄是/usr/local/bin/phpize,用sudo執行)
報錯出現Cannot find autoconf. Please check your autoconf 
查原因是需要裝autoconf 
Brew install autoconf 
ok 后
./configure --enable-xdebug 
make && make install

 

  方式二
用brew search php 找到xdebug擴展 
brew install homebrew/php/xdebug-osx

 

 
安裝完成,出現如下提示:
Installing shared extensions:     /usr/local/Cellar/php56/5.6.32_8/lib/php/extensions/no-debug-non-zts-20131226/
+----------------------------------------------------------------------+
  |                                                                      |
  |   INSTALLATION INSTRUCTIONS                                          |
  |   =========================                                          |
  |                                                                      |
  |   See http://xdebug.org/install.php#configure-php for instructions   |
  |   on how to enable Xdebug for PHP.                                   |
  |                                                                      |
  |   Documentation is available online as well:                         |
  |   - A list of all settings:  http://xdebug.org/docs-settings.php     |
  |   - A list of all functions: http://xdebug.org/docs-functions.php    
  |
  |   - Profiling instructions:  http://xdebug.org/docs-profiling2.php   
  |
  |   - Remote debugging:        http://xdebug.org/docs-debugger.php     |
  |                                                                      |
  |                                                                      |
  |   NOTE: Please disregard the message                                 |
  |       You should add "extension=xdebug.so" to php.ini                |
  |   that is emitted by the PECL installer. This does not work for      |
  |   Xdebug.                                                            |
  |                                                                      |
  +----------------------------------------------------------------------+
 

 

 
配置php.ini,在phpinfo里看清楚自己的配置文件
[Xdebug]
;extension=php_xdebug.dll
zend_extension = "/usr/local/Cellar/php56/5.6.32_8/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
xdebug.auto_trace=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.trace_output_dir="/usr/local/var/xdebug/trace"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/usr/local/var/xdebug/profiler"
xdebug.remote_autostart=1 #自動
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=9050  #我用的php-fpm方式啟動的PHP,9000端口被它占了,所以換端口
xdebug.remote_handler = "dbgp"
xdebug.idekey = PHPSTORM #可不寫,默認會是環境變量

 

重啟php
 
以上是配置php支持xdebug,用php -v 或者phpinfo 看到xdebug開了就行了。
 
----------------------------------------------
設置phpstorm監聽xdebug 折騰了近2天,真是
起初應該是PHP和xdebug不匹配,直接下了個2.5.5的,檢測過沒注意到說要2.5.4,然后入坑里出不來,以上的配置主要是extension的路徑要寫對,autostart 配置為1,
以上這些配置在xdebug官網里都有說明,不過關鍵的xdebug的原理看 https://xdebug.org/docs/remote
dbgp的說明:https://xdebug.org/docs-dbgp.php#standard-dbgp-port
 
------
說phpstorm里的配置,在
dbgp的默認端口應該都是80吧,ide key 寫配置里的值就好,端口應該都是80,開始時默認是9001沒改
 
 -----------------------------
另外補充,點蟲子邊上的edit config里的幾個配置介紹
都有說明
 
 
如有任何問題,評論聯系~ 
 
 


免責聲明!

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



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