本文以Mac为例,如果是Windows则将docker.for.mac.localhost改为 docker.for.win.localhost
1. 首先打开 laradock 项目的 .env 文件,定位到下面两行:
# laradock/.env
WORKSPACE_INSTALL_XDEBUG=true
PHP_FPM_INSTALL_XDEBUG=false
将这两个选项设为 true 会分别在 workspace 和 php-fpm 容器中安装 xdebug 拓展
在 php-fpm 中安装 xdebug 是用来调试 Http 请求,比如调试浏览器、Postman 发起的请求,workspace 中安装 xdebug 可以调试 CLI 请求,比如 Artisan 命令、PHP 脚本
2. 打开 laradock/php-fpm/xdebug.ini 文件,将前两行修改为如下:
# laradock/php-fpm/xdebug.ini
xdebug.remote_host=docker.for.mac.localhost
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.var_displa