Is PHP debugging supposed to work?

I tried to debug a PHP application. I also tried the Symfony demo.

The first problem is that the Apache that gets launched by default does not have debugging enabled.

Then, in the debugger I can launch another instance, I can set a breakpoint, and execution stops there. But then the process dies. This is not helpful at all.

On https://www.gitpod.io/docs/languages/php/ the demo shown in the animated gif has only simple variable-setting code that runs once and exists. The demo does not even use the HTML Preview.

However, as we all know, PHP is used for websites where a request comes in and some code produces a response. And that response is shown in the HTML Preview where the server continues running. That is what I want to debug. Not simple variable-setting code.

So, my question is, after seeing PHP debugging advertised on the Gitpod website, is PHP debugging working at all for real applications?

Then, show me an example where this works.

Hello, sorry PHP debugging isn’t working for you. Could you send a link to the repository where the issue is occurring?

Hello, so basically what we would like to do is to have a server running (apache in this case) and the debug working in real time on the preview of the website.
So if I have a variable printed, but I rewrite the value of it in the console it should update on the live site without the server or debug stopping.
Used the PHP example gitpod to demonstrate it kind of https://github.com/tetsuroba/Gitpod-PHP-Debug

I’m not quite sure how this should work in the GitPod environment but it works in local VSC environment.
Kind of like in this video https://youtu.be/LNIvugvmCyQ

Thanks in advance.

So I got your example working on the basis that I can see the variables set and stuff however the website does not render in real time as the response doesn’t seem to be sent until after the PHP script is run, however they way XDebug seems to work is that it must call to PHP I got your example running with php -S localhost:8080 -t public/ then starting the listen for XDebug thing in the debug menu, creating a breakpoint, and finally making a request it should then stop on the breakpoint letting you see the variables

Let me know if this helps!

We gave up. The environment is too limited. Not even email sending worked because of port limitation. No ssh.

@JesterOrNot

So I got your example working on the basis that I can see the variables set and stuff however the website does not render in real time as the response doesn’t seem to be sent until after the PHP script is run, however they way XDebug seems to work is that it must call to PHP I got your example running with php -S localhost:8080 -t public/ then starting the listen for XDebug thing in the debug menu, creating a breakpoint, and finally making a request it should then stop on the breakpoint letting you see the variables

I followed these directions exactly with the repo: https://github.com/tetsuroba/Gitpod-PHP-Debug/ and code execution does not halt on any breakpoints i set in /public/index.php

I don’t need the realtime rendering part of it, however I do need the debugger to work when the browser preview makes a request. Any advice?

UPDATE: looked like xdebug was failing in someway so I added a log and set xdebug.remote_connect_back = 1 in php.ini and got this when tailing the log (ip address masked for security):

xdebug error log:
[1832] Log opened at 2021-01-09 21:44:54
[1832] I: Checking remote connect back address.
[1832] I: Checking header ‘HTTP_X_FORWARDED_FOR’.
[1832] I: Remote address found, connecting to XX.XXX.X.XX:9000.
[1832] W: Creating socket for ‘XX.XXX.X.XX:9000’, poll success, but error: Operation now in progress (29).
[1832] E: Could not connect to client. :frowning:
[1832] Log closed at 2021-01-09 21:44:54

Hi @Devz3n,

I was able to reproduce the problem, and then managed it to fix it somehow. Here is what I did:

  1. Open https://gitpod.io/#https://github.com/tetsuroba/Gitpod-PHP-Debug
  2. Go to the Extensions panel in the left vertical menu
  3. Search for “PHP Debug”, and update the installed “PHP Debug” extension
  4. Refresh the Gitpod tab
  5. Run php -S localhost:8080 -t public/ in a Terminal, and open port 8080 in a preview
  6. Set a breakpoint somewhere in public/index.php
  7. Go to the Debug panel in the left vertical menu
  8. Click on the “Start” button next to “Listen for XDebug”
  9. Refresh the preview

This should stop on the breakpoint you set, and allow you to debug & step through the code.

Likely the “PHP Debug” extension is outdated in the example repo. I’ll see if I can update it it.

Update: I’ve sent a Pull Request to the example repo: https://github.com/tetsuroba/Gitpod-PHP-Debug/pull/1