XDebug only writes to log for CLI scripts and not browser requests

205 Views Asked by At

I'm trying to diagnose why PhpStorm seems to lose its connection after a while to XDebug 3 running in a Docker container on Windows, so I have xdebug.log=/path/to/xdebug.log in a .ini file and I'm looking at that log file.

XDebug successfully does step debugging for both browser requests and CLI scripts, but it only writes to the log when CLI scripts are being executed. The log remains unchanged throughout step debugging if a browser request is being processed.

Why would CLI vs. browser make a difference to XDebug's logging? How can I enable it for browser requests?

1

There are 1 best solutions below

0
On BEST ANSWER

PHP on the CLI, and the PHP that runs through the web server might have different INI files. You can check which ones are used by using php --ini on the CLI, or using phpinfo() in a script that's run through the browser.

If they're using the same INI file, then check whether the value of xdebug.log is correct. Using php -m xdebug | grep log on the CLI, or again phpinfo() in a script.

If these are both correct, then it could also be a permissions issue. If the /path/to/xdebug.log has been created by the user that runs CLI commands (likely: you), then the webserver user will likely not have permissions to write to it too. You can check the owner and access rights of the log file with ls -l /path/to/xdebug.

It is also possible that the webserver user does not even have access to the /path/to part, which you can check with ls -l /path/to/, and verify whether the webserver user is part of the access mask.

If this is your personal machine (and not anything shared, or in production), you can fix the permissions on /path/to/xdebug.log with chmod 0666 /path/to/xdebug.log which should give all users write access to that file.