Skip to content
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

Support XDebug on Linux #185

Merged
merged 7 commits into from
Jul 15, 2020
Merged

Support XDebug on Linux #185

merged 7 commits into from
Jul 15, 2020

Conversation

roborourke
Copy link
Contributor

Fixes #184

This update uses the XDEBUG_CONFIG environment variable to set two things:

  • idekey: this enables xdebug for every run of PHP and handles setting the cookie if not already present
  • remote_host: host.docker.internal is a special value for Windows and Mac only, Linux distros can use the static IP 172.17.0.1 to communicate with the host machine

Because xdebug is switched on or off by switching container I think its ok to run every time. This has the added benefit of being able to use xdebug with CLI commands.

Fixes #184

This changes from manually setting the XDEBUG_SESSION cookie and relying remote enabling in favour of setting the XDEBUG_CONFIG environment variable. This will ensure that the debugger connects every time and will handle setting the cookie itself.

This also means XDebug can be used to debug CLI commands.

Given that local server has 2 separate modes, with & without xdebug having it always be on in xdebug mode is worth the performance hit as developers can easily switch back.
@roborourke roborourke requested a review from kadamwhite July 15, 2020 13:29
Copy link

@hm-linter hm-linter bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting failed (2 errors).

I forgot that although the container is running PHP 7.2 the host machine where `PHP_OS_FAMILY` is in use might not be.
Copy link
Contributor

@kadamwhite kadamwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're a life saver, @roborourke !

@roborourke roborourke merged commit eeb58cd into master Jul 15, 2020
@roborourke roborourke deleted the fix-xdebug-vscode branch July 15, 2020 14:57
@hm-backport
Copy link

hm-backport bot commented Jul 15, 2020

The backport to v3-branch failed:

Reference already exists

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport v3-branch
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick 37a1a28565b7a028dc4bf7d895c3bd5f2704c47b 3ac5c5fe8129699599bfc140336140a54c06bdab 007fa5b4512b52a1d78e09af170bfb7b24fda9c0 5afaa32ecaa09b4f4d7d3a89c9c8cbaceeb52580 fed9436329628728a9a3e51a561f0e21f7892242 699c9d69d0ff61349d4fd2db202f8b23702e926b a36668d2209bc590ea88fbf0be06f2c2de11c390
# Create a new branch with these backported commits.
git checkout -b backport-185-to-v3-branch
# Push it to GitHub.
git push --set-upstream origin backport-185-to-v3-branch
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is v3-branch and the compare/head branch is backport-185-to-v3-branch.

@hm-backport
Copy link

hm-backport bot commented Jul 15, 2020

The backport to v3-branch failed:

Commits ["37a1a28565b7a028dc4bf7d895c3bd5f2704c47b","3ac5c5fe8129699599bfc140336140a54c06bdab","007fa5b4512b52a1d78e09af170bfb7b24fda9c0","5afaa32ecaa09b4f4d7d3a89c9c8cbaceeb52580","fed9436329628728a9a3e51a561f0e21f7892242","699c9d69d0ff61349d4fd2db202f8b23702e926b","a36668d2209bc590ea88fbf0be06f2c2de11c390"] could not be cherry-picked on top of v3-branch

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport v3-branch
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick 37a1a28565b7a028dc4bf7d895c3bd5f2704c47b 3ac5c5fe8129699599bfc140336140a54c06bdab 007fa5b4512b52a1d78e09af170bfb7b24fda9c0 5afaa32ecaa09b4f4d7d3a89c9c8cbaceeb52580 fed9436329628728a9a3e51a561f0e21f7892242 699c9d69d0ff61349d4fd2db202f8b23702e926b a36668d2209bc590ea88fbf0be06f2c2de11c390
# Create a new branch with these backported commits.
git checkout -b backport-185-to-v3-branch
# Push it to GitHub.
git push --set-upstream origin backport-185-to-v3-branch
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is v3-branch and the compare/head branch is backport-185-to-v3-branch.

@hm-backport
Copy link

hm-backport bot commented Jul 15, 2020

The backport to v4-branch failed:

Reference already exists

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport v4-branch
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick 37a1a28565b7a028dc4bf7d895c3bd5f2704c47b 3ac5c5fe8129699599bfc140336140a54c06bdab 007fa5b4512b52a1d78e09af170bfb7b24fda9c0 5afaa32ecaa09b4f4d7d3a89c9c8cbaceeb52580 fed9436329628728a9a3e51a561f0e21f7892242 699c9d69d0ff61349d4fd2db202f8b23702e926b a36668d2209bc590ea88fbf0be06f2c2de11c390
# Create a new branch with these backported commits.
git checkout -b backport-185-to-v4-branch
# Push it to GitHub.
git push --set-upstream origin backport-185-to-v4-branch
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is v4-branch and the compare/head branch is backport-185-to-v4-branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XDebug not working out of the box in VSCode
2 participants