1.环境准备
1.开发工具下载:PhpStorm: PHP IDE and Code Editor from JetBrains
2.PHP下载:PHP: Downloads
- PHP扩展:PECL :: Package search
4.用与调试的xdebug模块: Xdebug: Downloads
xdebug模块,如果是php8以下版本,需要用2版本的xdebug,如果是php8以上的版本,则用3版本的xdebug
2.windows下操作【本次使用TS线程安全版本操作,使用php7.4版本】
- wondows版php7.4:https://windows.php.net/downloads/releases/archives/php-7.4.9-Win32-vc15-x64.zip
- php-redis5.3.2:https://windows.php.net/downloads/pecl/releases/redis/5.3.2/php_redis-5.3.2-7.4-ts-vc15-x64.zip
- xdebug2.9.8:https://xdebug.org/files/php_xdebug-2.9.8-7.4-vc15-x86_64.dll
3.配置PHP环境和xdebug模块
1.将php7.4下载好的包解压,并放到相应目录,估计后期会常用,可以放到 C:\Program Files 目录下
2.在 C:\Program Files\php-7.4.9-Win32-vc15-x64 目录下,复制 php.ini-development ,并将复制的名字修改为 php.ini
3.将下载好的 xdebug 文件 复制到 C:\Program Files\php-7.4.9-Win32-vc15-x64\ext 里面,并重命名为 php_xdebug.dll
4.修改php.ini文件,在最底部增加 xdebug 相关配置,增加内容如下
bash
[xdebug]
zend_extension=xdebug
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9003
5.本项目还使用了redis模块,同时将下载好的redis.dll 文件如第三步一样,复制到 ext目录下,并重命名为 php_redis.dll
- 同时修改php.ini文件,并在最后增加如下配置
bash
extension=redis
7.windows平台下由于默认ext目录为c:,因此需要在php.ini最后添加如下配置
extension_dir = "ext"
保存配置文件并关闭编辑
4.配置phpstorm
Ctrl + Alt + S 打开设置

添加PHP版本



5.配置启动服务,使用内置的php服务器进行启动




点击连接,会自动打开浏览器
验证一下xdebug配置是否正常


上图就意味着xdebug配置没有问题
安装浏览器debug插件

点击打开浏览器,由于我本人使用的是 edge浏览器,因此打开这个




调试测试


刷新页面,就会进入调试模式
