Mac的laradock配置xdebug

一.首先吐槽下,看过网上教程好几个,按照教程配置,怎么也不成功,后来发现是本地的9000端口被php-fpm占用了,解决掉终于OK了。

二.配置步骤如下:

1.laradock目录下的.env   

WORKSPACE_INSTALL_XDEBUG=true

PHP_FPM_INSTALL_XDEBUG=true

2.修改Laradock/PHP-FPM/xdebug.ini 

; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-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_display_max_children=-1
  xdebug.var_display_max_data=-1
  xdebug.var_display_max_depth=-1

3.重新 build 容器

docker-compose build workspace php-fpm

4.重启容器

docker-compose down && docker-compose up -d nginx mysql redis 

5.PHPStorm 设置:Preferences->Language & Frameworks->PHP->Servers,新建一个 server,这里取名 laradocker。

Mac的laradock配置xdebug_第1张图片

6.Host 里面填入 laradock。这是因为laradoc/.env 文件里面有一行设置了 serverName。

### Remote Interpreter ####################################

# Choose a Remote Interpreter entry matching name. Default is `laradock`

PHP_IDE_CONFIG=serverName=laradock

7.配置 Run->Edit Configuration

Mac的laradock配置xdebug_第2张图片

8.工具栏的Run下配置

Mac的laradock配置xdebug_第3张图片

9.开启调试 完成配置

Mac的laradock配置xdebug_第4张图片

三.总结

1.网上教程说:在 laradock 目录下面执行 ./php-fpm/xdebug start 开启  这个不开启也不影响使用。

laradocker目录下的workspace/xdebug.ini可不配置,

2.开启debug报错如下

Mac的laradock配置xdebug_第5张图片

原因是本地php-fpm也占用了9000端口

Mac的laradock配置xdebug_第6张图片

卸载了本地的php-fpm,就OK了

Mac的laradock配置xdebug_第7张图片

2.另外开启debug时一直报如图的错误,不知什么原因,也没搞明白

3.最后感慨下,花费我几个小时,入坑挺折腾的。

你可能感兴趣的:(PHP,Laravel,docker,laradocker,xdebug,laravel)