摘要
项目使用的技术栈:PHP 7.4.33、ThinkPHP 5.1.27、Redis、MySQL
由于MacOS预装的PHP版本较高,所以需要降级
IDE 使用 PhpStorm 2023.2.3
1. 安装PHP 7.4.33
MacOS 14中的brew版本比较高,没有低版本的PHP
brew install shivammathur/php/php@7.4-debug
2. 切换版本
#断开链接php8.3版本
brew unlink php@8.3
#链接php7.4版本
brew link php@7.4-debug
3. 安装xdebug模块
3.1 确认xdebug版本
将phpinfo()粘贴到xdebug提供的安装向导页面 Installation Wizard
3.2 安装xdebug
根据上一步中分析的结果,安装对应版本的xdebug
4. 安装Redis模块
4.1 下载Redis模块的源码包
4.2 安装
解压缩后进入目录 Downloads/redis-5.0.2/redis-5.0.2
yang@yangdeMBP redis-5.0.2 % ll
total 3656
drwxr-xr-x@ 56 yang staff 1792 4 3 09:48 ./
drwxr-xr-x@ 5 yang staff 160 4 3 09:42 ../
drwxr-xr-x 14 yang staff 448 4 3 09:48 .libs/
-rw-r--r--@ 1 yang staff 3218 7 29 2019 COPYING
-rw-r--r--@ 1 yang staff 204 7 29 2019 CREDITS
-rw-r--r--@ 1 yang staff 3602 7 29 2019 INSTALL.markdown
-rw-r--r-- 1 yang staff 11894 4 3 09:48 Makefile
-rw-r--r-- 1 yang staff 0 4 3 09:48 Makefile.fragments
-rw-r--r-- 1 yang staff 2802 4 3 09:48 Makefile.objects
-rw-r--r--@ 1 yang staff 119355 7 29 2019 README.markdown
-rw-r--r--@ 1 yang staff 10019 7 29 2019 arrays.markdown
drwxr-xr-x 7 yang staff 224 4 3 09:45 autom4te.cache/
drwxr-xr-x 13 yang staff 416 4 3 09:45 build/
-rw-r--r--@ 1 yang staff 10988 7 29 2019 cluster.markdown
-rw-r--r--@ 1 yang staff 83920 7 29 2019 cluster_library.c
-rw-r--r--@ 1 yang staff 18106 7 29 2019 cluster_library.h
-rw-r--r-- 1 yang staff 321 4 3 09:48 cluster_library.lo
-rw-r--r--@ 1 yang staff 19955 7 29 2019 common.h
-rw-r--r-- 1 yang staff 2131 4 3 09:45 config.h
-rw-r--r-- 1 yang staff 2006 4 3 09:48 config.h.in
-rw-r--r-- 1 yang staff 18298 4 3 09:48 config.log
-rw-r--r--@ 1 yang staff 7802 7 29 2019 config.m4
-rwxr-xr-x 1 yang staff 139 4 3 09:48 config.nice*
-rwxr-xr-x 1 yang staff 21221 4 3 09:48 config.status*
-rw-r--r--@ 1 yang staff 923 7 29 2019 config.w32
-rwxr-xr-x 1 yang staff 475668 4 3 09:45 configure*
-rw-r--r-- 1 yang staff 5082 4 3 09:45 configure.ac
-rw-r--r--@ 1 yang staff 4483 7 29 2019 crc16.h
drwxr-xr-x 2 yang staff 64 4 3 09:45 include/
drwxr-xr-x@ 8 yang staff 256 4 3 09:42 liblzf/
-rw-r--r--@ 1 yang staff 78234 7 29 2019 library.c
-rw-r--r--@ 1 yang staff 8056 7 29 2019 library.h
-rw-r--r-- 1 yang staff 305 4 3 09:48 library.lo
-rwxr-xr-x 1 yang staff 211007 4 3 09:48 libtool*
drwxr-xr-x 3 yang staff 96 4 3 09:48 modules/
-rw-r--r--@ 1 yang staff 8509 7 29 2019 php_redis.h
-rw-r--r--@ 1 yang staff 116912 7 29 2019 redis.c
-rw-r--r-- 1 yang staff 802 4 3 09:48 redis.la
-rw-r--r-- 1 yang staff 301 4 3 09:48 redis.lo
-rw-r--r--@ 1 yang staff 40509 7 29 2019 redis_array.c
-rw-r--r--@ 1 yang staff 2281 7 29 2019 redis_array.h
-rw-r--r-- 1 yang staff 313 4 3 09:48 redis_array.lo
-rw-r--r--@ 1 yang staff 40728 7 29 2019 redis_array_impl.c
-rw-r--r--@ 1 yang staff 1350 7 29 2019 redis_array_impl.h
-rw-r--r-- 1 yang staff 323 4 3 09:48 redis_array_impl.lo
-rw-r--r--@ 1 yang staff 106555 7 29 2019 redis_cluster.c
-rw-r--r--@ 1 yang staff 10438 7 29 2019 redis_cluster.h
-rw-r--r-- 1 yang staff 317 4 3 09:48 redis_cluster.lo
-rw-r--r--@ 1 yang staff 130272 7 29 2019 redis_commands.c
-rw-r--r--@ 1 yang staff 13712 7 29 2019 redis_commands.h
-rw-r--r-- 1 yang staff 319 4 3 09:48 redis_commands.lo
-rw-r--r--@ 1 yang staff 35238 7 29 2019 redis_session.c
-rw-r--r--@ 1 yang staff 511 7 29 2019 redis_session.h
-rw-r--r-- 1 yang staff 317 4 3 09:48 redis_session.lo
-r-xr-xr-x 1 yang staff 127055 4 3 09:45 run-tests.php*
drwxr-xr-x@ 12 yang staff 384 4 3 09:42 tests/
按顺序执行命令
yang@yangdeMBP redis-5.0.2 % phpize
yang@yangdeMBP redis-5.0.2 % ./configure --with-php-config=/opt/homebrew/Cellar/php@7.4-debug/7.4.33_6/bin/php-config
yang@yangdeMBP redis-5.0.2 % make && make install
5. 修改php.ini配置
增加xdebug和Redis扩展
zend_extension = "/opt/homebrew/lib/php/pecl/20190902-debug/xdebug.so"
xdebug.remote_handler="dbgp"
xdebug.client_host=localhost
xdebug.client_port=9001
xdebug.idekey=phpstorm
xdebug.start_with_request=yes
xdebug.mode=debug
extension="/opt/homebrew/lib/php/pecl/20190902-debug/redis.so"
6. 配置PhpStorm,使可以debug
6.1 配置PHP解释器
6.2 配置xdebug端口
端口应该和php.ini中的一致
6.3 配置DBGp代理
这里的ide键就是php.ini文件中的xdebug.idekey的值