Homestead+PhpStorm+Xdebug 远程调试
配置Homestead
- 通过ssh登录到虚拟机中
- 通过命令找到网关(用于配置后续的remote_host)
netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10
- 编辑xdebug的配置文件
sudo vim /etc/php/7.2/fpm/conf.d/20-xdebug.ini
zend_extension=xdebug.so xdebug.remote_enable = 1 xdebug.remote_port=9000 # 远程通信端口 xdebug.max_nesting_level=512 xdebug.remote_host=10.0.2.2 # 上文中提到的网关地址 xdebug.remote_autostart=1 # 自动启动设为true
- 重启nginx和php
sudo service php7.2-fpm restart sudo service nginx restart
配置phpstorm
- 打开设置,依次选择Languages & Frameworks => PHP ,进行对应的设置 密码为
vagrant
- 配置路径映射
- Xebug,一般默认设置就行
- 点击Validate进行验证,将本地的public目录和远程的访问url填写后,点击Validate,对应有不对的依照提示更改
- 配置Servers,host填写app的地址,注意进行map映射本地和远程目录
- 点击Run=>Edit Configrations,新增一个PHP Remote Debug
- 至此,phpstorm配置完成,点击图标开始监听,然后点击绿色小虫开始debug
使用浏览器打开网页进行调试
http://shop.test/?XDEBUG_SESSION_START=PHP...
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: