New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homestead Laravel Xdebug #220
Comments
I too have this issue and as far as I can see they problem is multiple connections. It spins up 2 connections which block each other. I can't figure out if this is XDebug on the Vagrant box which causes the problem, or if it is standard behaviour the PHP Debugger in VSCode somehow is mishandling? Starting PHP Debug in VSCode and launching PHPUnit on the vagrant box produces these logs:
Vagrant XDebug (xdebug.remote_log)
If I then hit the stop button in VSCode, thread 2 is closed and the first test completes (but then spins up a thread #3). If I hit the stop again then thread 1 and 3 closes (effectively ending PHP Debug) and the final test completes. No breakpoints are ever hit. When this is done the logs look like this VSCode log
Vagrant XDebug (xdebug.remote_log)
|
After some troubleshooting i've fixed the issue |
No one could help us? |
Besides this bug that will break your workflow when there are more than one request at the same time, I can make it work with Homestead v7.3.0 (Box 5.2.0) using this config: xdebug.ini:
VERY IMPORTANT: remove any other xdebug configuration besides the ones above. Using things like launch.json:
Full Step by Step Guide:Setup Xdebug in Homestead
Setup Xdebug in VSCode
IMPORTANT: if pathMapping is incorrect breakpoints will not stop. Make sure your local and server paths are correct. You can also try with this:
|
I couldn't get it to work either at first what ended up being the case for me is that port 9000 was already in use by my local php installation's xdebug. An easy fix was to move xdebug on vagrant to port 9001 and reflect this in your local launch.json |
I couldn`t get it to work either i got an error PHP Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/lib/php/20170718/xdebug.so (/usr/lib/php/20170718/xdebug.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/xdebug.so.so (/usr/lib/php/20170718/xdebug.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 |
I also had problems using the debugger properly. It started, but I didn't see in which line it was. Of course, only for a breakpoint, this was the right line. The solution of the problem was the entry of all 3 lines for pathMapping as already described by @jonagoldman:
|
@kmaradona this is because newer homestead comes with php7.2, which does not have xdebug installed in its stable version yet. You can install it via the following instructions |
I had many of the same issues, although not using Homestead. I've just today managed to get this working for myself. In the end when I added My fully config looks like this:
|
Quick question, I'm also having issues and I want to check the logs files, but I can't find them anywhere. Not the VScode ones and not the ones on the server, where can I find them? |
Also, when restarting the |
I have a quick question. |
@jonagoldman And when i click the Create File button it creates file on my local machine. Here is my settings:
If you need more info of my environment just let me know 🙏 |
First, you are assumming that the error you see is related to the debbuger but are you sure it is related in some way? It looks to me that the file is not found, nothing to do with the plugin. The create file button is just a helper, you are not supposed to create the file, you should look why it is not finding the file. Do your project run without any warnings in the laravel log file? Your .yaml file looks strange, the folder mapping will map all the folder contents, so you should not map a folder inside a folder you have already mapped. Remember, you are mapping folders not websites! So why are you mapping 'Laravel/phpMyAdmin' if you have already mapped the 'Laravel' folder? I don't know how to help you any more that that, you should dig deeper to see why the file is not found. Also try using a regular path not {$workspaceFolder}! Try different things until it works. Good look! |
Again, Thank you for your quick answer 🙏 and yes my project just runs fine without any error. |
I finally figured where that file not found error comes from there was typo in the lauch.json. |
Don't use ${workspaceFolder}" or ${workspaceRoot} in the path, try the full real path, and double check everything! |
If it can help somebody, this pathMapping worked for me @jonagoldman thank you !! 🙏💪 |
From my experience, here are a few things that I think we can check if cannot get Xdebug work with vagrant
|
I spent two hours trying to get this to work and the above worked for me. If you have been using xdebug with a local PHP instance through xampp or even locally running Laravel then make sure your port is different on the homestead instance otherwise they conflict and nothing works. To be safe I changed my port to 9010 and works beautifully. |
Hi there.
xdebug.remote_port the default port in the v3.x changed from 9000 to 9003 (remember to change it in the VScode json config) With all this changes and the relative fixes in the VSCODE json file (for the debug php plugin) I was able to use the php breakpoints and debug. |
Hi there,
I can't figure out Xdebug to work with VSCode and Laravel/Homestead. I spent a lot of hours trying to fix it. What i'm doing wrong? Thanks for the help guys.
XDebug logfile:
Log opened at 2017-12-27 18:05:11
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 192.168.10.1:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-12-27 18:05:12
Log opened at 2017-12-27 18:05:13
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 192.168.10.1:9000.
E: Time-out connecting to client. :-(
Log closed at 2017-12-27 18:05:13`
PHP version:
XDebug version:
v2.5.5
Vagrant version:
2.0.1
Virtualbox version:
5.2.2
Laravel version:
5.5.26
vscode-php-debug version:
1.12.1
My PC:
Windows 10
Index.php location on my PC:
D:\Project\Project\public
Homestead config file:
Your launch.json:
XDebug php.ini(20-xdebug.ini) config, loaded as additional .ini in
/etc/php/7.1/fpm/conf.d/20-xdebug.ini
10.0.2.2
comes from this command:netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10
Adapter logfile when debug start:
<- launchResponse
Response {
seq: 0,
type: 'response',
request_seq: 2,
command: 'launch',
success: true }
Adapter logfile when I stop manually the debug:
-> disconnectRequest
{ command: 'disconnect',
arguments: { restart: false },
type: 'request',
seq: 3 }
<- disconnectResponse
Response {
seq: 0,
type: 'response',
request_seq: 3,
command: 'disconnect',
success: true }
more details from phpinfo():
The text was updated successfully, but these errors were encountered: