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里的几个配置介绍
都有说明
 
 
如有任何问题,评论联系~ 
 
 
posted @ 2017-11-17 20:32  yeevan  阅读(2957)  评论(0编辑  收藏  举报