Homestead 2 xdebug doesn't work

2019-05-05 15:43发布

问题:

I have a Homestead vagrant VM setup. Xdebug is all setup for remote debugging out of the box.

I can see this in here /etc/php5/fpm/conf.d/20-xdebug.ini and by doing a php -i | grep 'xdebug'

I've setup a breakpoint in my default index.php and clicked the 'start listening for PHP debug connections' in my IDE PHPstorm.

I have installed xdebug helper for chrome and turned it on, also setting my IDE string to PHPstorm in it's settings.

I've tried setting different ports in both my IDE and xdebug settings.

I've also tried listening to these ports with sudo nc -l 9002 on both host and guest machines, nothing connects so the problem here is definitely with xdebug settings in the PHP server.

回答1:

Posting my own answer here for posterity in the hope it saves someone time as I trawled google for an answer and spent several hours stuck on this.

When doing a sudo netstat -taupen I saw HHVM was listening on port 9000 on the VM which should have been a clue to why it wasn't working, I set hhvm: false in my homestead.yaml to no avail.

After more fiddling I saw that phpinfo() was giving a message of 'HipHop', A quick look at Google again led me to HHVM.

What I didn't do before was reprovision my homestead which sometimes is needed when changing stuff in the config. So after a homestead provision HHVM was fully disabled and xdebug was working.

Also word of warning, editing xdebug settings in the ini requires a restart of php fpm, nginx alone is not enough. Do a sudo service php5-fpm restart.



回答2:

Just a quick note I tried all of the above provided solutions

My Solution:

for PHP7, Laravel 5.3 and homestead

vagrant ssh

sudo apt-get purge hhvm && sudo service nginx restart

After purging hhvm from the system xDebug works as expected.

Description:

In newer versions of laravel/homestead hhvm is not supported anymore but is still running!

They took all descriptions out of the documentation. (Laravel 5.3)

hhvm: false in the Homestead.yml config does not work anymore!

Tried it in every possible location of the Homestead.yml file, but if you reprovision and boot up homestead the hhvm instance is still running and listening on port 9000...

First I tried to change xDebugs listening port to 9089 which did not work. (yes I restarted fpm)

At some point I got annoyed and purged hhvm from the homestead vm.

Now everything works as expected.

Note: The provisioning is not reinstalling it.

Hope this helps someone and thanks for pointing me into the right direction