本地xdebug调试搭建 Laravel+homestead+phpstorm

1.在homestead virtual box安装和配置xdebug

先在终端运行vagrant up 和 vagrant ssh,ssh远程到homestead,然后复制以下代码到一个shell文件里面,并执行。

#!bash/bin
cd ~
#download and uncompress
wget https://xdebug.org/files/xdebug-2.4.0.tgz
tar xvzf xdebug-2.4.0.tgz

#compile and make install
cd xdebug-2.4.0
phpize7.0
./configure --enable-xdebug
make
sudo make install

mkdir -p /usr/local/php/xdebug
sudo cp ~/xdebug-2.4.0/modules/xdebug.so /usr/local/php/xdebug/xdebug.so
cat>>xdebug.ini<<EOF
zend_extension="/usr/local/php/xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 500
EOF

sudo cp xdebug.ini /etc/php/mods-available/xdebug.ini
sudo ln -snf /etc/php/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini
sudo ln -snf /etc/php/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini

service php7.0-fpm restart

cd ~
sudo rm -R xdebug-2.4.0
sudo rm  xdebug-2.4.0.tgz

2.根据浏览器安装xdebug插件

Xdebug Helper for Chrome or  JetBrains IDE Support 

Xdebug Toggler for Safari

3.PHPStorm配置xdebug

3.1在导航上 Run->edit Configurations... 进入以下界面

本地xdebug调试搭建 Laravel+homestead+phpstorm

 本地xdebug调试搭建 Laravel+homestead+phpstorm

根据上图设置保存设置。

运行debug; 设置断点,然后 运行 Run->debug,如下图:

 

本地xdebug调试搭建 Laravel+homestead+phpstorm

运行成功KO!

 

 

参考资料:

https://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide