Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit d04ea82

Browse files
Copilotdermatz
andcommitted
Add XDEBUG_MODE=off to all DDEV commands to fix Xdebug hang issue
Co-authored-by: dermatz <6103201+dermatz@users.noreply.github.com>
1 parent 8e48538 commit d04ea82

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ PHPStan uses different exit codes to indicate different states:
138138

139139
The extension handles exit codes 0 and 1 as successful execution, only treating exit code 2 and higher as actual failures.
140140

141+
### Xdebug compatibility
142+
143+
The extension automatically disables Xdebug for PHPStan analysis commands to prevent performance issues and hangs. When Xdebug is enabled in your DDEV container for debugging web requests, it can significantly slow down or cause CLI commands like PHPStan to hang.
144+
145+
The extension uses `XDEBUG_MODE=off` when executing PHPStan commands, which:
146+
- Prevents Xdebug from interfering with PHPStan analysis
147+
- Improves analysis performance
148+
- Avoids timeout issues when Xdebug is waiting for a debugger connection
149+
- Does not affect your web debugging configuration
150+
151+
This is handled automatically and requires no configuration on your part.
152+
141153
### No issues detected
142154

143155
PHPStan might not find issues if:

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function debugAnalyzeCurrentFile() {
197197
// Show output in a new document
198198
vscode.workspace.openTextDocument({
199199
content: `PHPStan Debug Output for: ${relativePath}\n` +
200-
`Command: ddev exec ${command}\n` +
200+
`Command: XDEBUG_MODE=off ddev exec ${command}\n` +
201201
`Output length: ${output.length} characters\n` +
202202
`${'='.repeat(80)}\n\n` +
203203
output,

src/shared/utils/ddev-utils.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class DdevUtils {
6464
*/
6565
public static isDdevRunning(workspacePath: string): boolean {
6666
try {
67-
execSync('ddev exec echo "test"', {
67+
execSync('XDEBUG_MODE=off ddev exec echo "test"', {
6868
cwd: workspacePath,
6969
stdio: 'ignore'
7070
});
@@ -83,7 +83,7 @@ export class DdevUtils {
8383
*/
8484
public static isToolInstalled(toolName: string, workspacePath: string): boolean {
8585
try {
86-
execSync(`ddev exec ${toolName} --version`, {
86+
execSync(`XDEBUG_MODE=off ddev exec ${toolName} --version`, {
8787
cwd: workspacePath,
8888
stdio: 'ignore'
8989
});
@@ -112,7 +112,7 @@ export class DdevUtils {
112112

113113
// Try to run the tool
114114
try {
115-
execSync(`ddev exec ${toolName} --version`, {
115+
execSync(`XDEBUG_MODE=off ddev exec ${toolName} --version`, {
116116
cwd: workspacePath,
117117
stdio: 'ignore'
118118
});
@@ -188,7 +188,9 @@ export class DdevUtils {
188188
*/
189189
public static execDdev(command: string, workspacePath: string, allowedExitCodes: number[] = [0]): string {
190190
try {
191-
return execSync(`ddev exec ${command}`, {
191+
// Disable Xdebug for CLI commands to prevent hangs and performance issues
192+
// when Xdebug is enabled in the DDEV container
193+
return execSync(`XDEBUG_MODE=off ddev exec ${command}`, {
192194
cwd: workspacePath,
193195
encoding: 'utf-8'
194196
});
@@ -206,7 +208,7 @@ export class DdevUtils {
206208
(enhancedError as any).status = error.status;
207209
(enhancedError as any).stderr = error.stderr;
208210
(enhancedError as any).stdout = error.stdout;
209-
(enhancedError as any).command = `ddev exec ${command}`;
211+
(enhancedError as any).command = `XDEBUG_MODE=off ddev exec ${command}`;
210212
(enhancedError as any).workspacePath = workspacePath;
211213

212214
throw enhancedError;

0 commit comments

Comments
 (0)