Mac 使用自带php和Apache 安置配置Xdebug 开启本地调试模式
标签:
Mac 安置配置php xdebug 本地调试 0、道理图https://paper.seebug.org/308/
测试demo构建要领新建空白项目,目录选择Apache默认项目目录
1、下载xdebughttps://xdebug.org/files/xdebug-2.9.0.tgz
具体本身的版本要按照??的要领得出
2、使用官方检测指导工具https://xdebug.org/wizard
将phpinfo()打印内容的网页源码复制到框里,,点击检测,会得到提示
然后按照提示进行操纵
Instructions
Download xdebug-2.9.0.tgz
Install the pre-requisites for compiling PHP extensions. On your Mac, we only support installations with ‘homebrew‘, and brew install php && brew install autoconf should pull in the right packages.
Unpack the downloaded file with tar -xvzf xdebug-2.9.0.tgz
Run: cd xdebug-2.9.0
Run: phpize (See the if you don‘t have phpize).
As part of its output it should show:
Configuring for:
... Zend Module Api No: 20180731 Zend Extension Api No: 320180731If it does not, you are using the wrong phpize. Please follow and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/local/lib/php/pecl/20180731
Edit /usr/local/etc/php/7.3/php.ini /usr/local/etc/php/7.3/php.ini and add the line zend_extension = /usr/local/lib/php/pecl/20180731/xdebug.so Make sure that zend_extension = /usr/local/lib/php/pecl/20180731/xdebug.so is below the line for OPcache.
Restart the webserver
sudo apachectl restart
安置路径:/Users/taylor/workSoft/php-debug
3、配置php.inivim /usr/local/etc/php/7.3/php.ini
大写G到最后一样,添加配置
[xdebug]
zend_extension=http://www.mamicode.com/usr/local/lib/php/pecl/20180731/xdebug.so xdebug.remote_enable=1 xdebug.remote_autostart=1 xdebug.idekey=PHPSTORM xdebug.remote_handler=dbgp xdebug.remote_connect_back=1 xdebug.remote_host=localhost xdebug.remote_port=9050 xdebug.scream=0 xdebug.show_local_vars=1参数分析:
xdebug.remote_connect_back = 0 ,也是 Xdebug 的默认方法,这种情况下,Xdebug 在收到调试通知时会读取配置 xdebug.remote_host 和 xdebug.remote_port ,默认是 localhost:9000,然后向这个端口发送通知,这种方法只适合单一客户端开发调试
此外一种方法则是不绑定IP,xdebug.remote_connect_back = 1, Xdebug按照请求来源(REMOTE_HOST)来倡议调试。示例图如下:
remote_connect_back与remote_host,remote_port的关系
xdebug.remote_connect_back = 1 //如果开启此,将忽略下面的 xdebug.remote_host 的参数,也就是说不会读取phpstorm中xdebug插件dbgp proxy中的参数,任何ip挪用调试城市返回调试信息到该IP的remote_port端口中。
remote_host和remote_port
xdebug.remote_host=192.168.x.x //注意这里是,客户真个ip<即IDE的机器的ip,不是你的web server>xdebug.remote_port = 9001 //注意这里是,客户真个端口<即IDE的机器的ip,不是你的web server>
最终尝试功效是,xdebug.remote_port 任何没被占用的端口都可以
重启php-fpm
sudo killall php-fpm sudo php-fpm
或者 /etc/init.d/php73-fpm reload
再打印phpinfo就可以看到
4、配置phpstormdebug配置
servers配置
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31765.html