Mac M1+ PhpStorm + Xdebug 调试

1,175 阅读1分钟

1.首先我php版本是5.6和7.2两个版本,php5.6下载的是xdebug2.5.5,php7.2使用Homebrew在Linux和macOS上通过PECL安装Xdebug,命令是 pecl install xdebug

可以根据自己php版本在官网下载对应的xdebug版本, xdebug.org/download/hi…

2.解压 tar -xvzf xdebug-2.5.5.tgz

3.进入解压后的目录 cd xdebug-2.5.5

4.运行脚本生成 configure文件 phpize

5.安装与编译,--with-php-config目录后跟着自己php环境下的php-config文件路径

./configure --enable-xdebug --with-php-config=/opt/homebrew/opt/php@5.6/bin/php-config

make clean

make

make install

6.打开php.ini加入下面内容,里面没注释部分是xdebug2的配置,而;分号注释的配置是xdebug3以上版本的配置

xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= 127.0.0.1
xdebug.remote_port = 9003
xdebug.remote_autostart = On
xdebug.idekey = PHPSTORM
zend_extension="xdebug.so"
;xdebug.start_with_request = Yes
;xdebug.client_port=9003
;xdebug.mode=debug

7.重启php并按下面进行PhpStorm的xdebug配置

image.png

image.png

image.png

8.点击Debug进行测试