第一次写完整文章分享,也是很好奇自己的体质,按照很多人的教程配置还是踩了大大小小的坑,分享下自己的配置流程及坑:
首先,最重要的,查看自己的phpstorm版本!!确保在**2018.3
或之上
**。
(之前搞了一下午发现debug断点进入不停止,就是因为本人那时候版本是2017.5,泪奔~~~)
配置文件修改:
/项目目录/laradock/php-fpm/xdebug.ini
与/项目目录/laradock/workspace/xdebug.ini
替换下方配置:
//host选择下方两个中的一个 有些mac docker配置docker.for.mac.localhost不成功
xdebug.remote_host=host.docker.internal
;xdebug.remote_host=docker.for.mac.localhost
xdebug.remote_connect_back=0
; 配置端口号
xdebug.remote_port=9009
; 配置 key
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
- 重新构建workspace与php-fpm
注意:一定要开启VPN,不然会遇见类似如下
ERROR:Service 'php-fpm' failed to buildreturned a non-zero code: 100
【这个也坑了我超久】
然后在 /项目目录 下运行以下命令
➜ cd laradock
➜ docker-compose build workspace php-fpm
等待,漫长的等待,树叶绿了又黄,,,,
➜ docker-compose up -d nginx php-fpm //重启服务
-
配置PHPSTORM
command + ,
打开设置进入下面的目录,写上配置端口
添加services和映射目录关系:
-
配置当前项目的debug文件:
选择edit configurations
选择"+
" → “PHP-Remote-Debug
”
选择之前添加的services—laradock
之后打开电话监听:
⬇️
再点击小爬虫【 此处解决经常跳出artisan报错
ERROR:Can not find /var/www/artisan localy
】
在项目上打断点,浏览器访问刷新,看到下面就配置成功啦:
GOOD LUCK!