0

I have VS Code installed on my client (laptop).

PHP is installed on the server. However, since its shared hosting, I can't install anything myself (like Xdebug). Is possible to debug PHP (set breakpoints, step through code)? For example, can I use the Interactive PHP Debugger?

NuSphere PhpED IDE says that the debugger works with shared hosting. I found a tutorial on how to set it up. I'm hoping the same can be done with VS Code.

6
  • 1
    you should never debug on a live server. Instead, configure a local development server on your laptop and use it to test and debug your code Commented Aug 11, 2024 at 7:05
  • You might be confusing development with production. I've tried testing locally, and almost always the problem was the local environment was using different software and versions than the development environment. Commented Aug 12, 2024 at 2:59
  • I don't confuse anything. If you have issues with environment, then you have to recreate it using docker. Still debugging on a live server is not what you should be doing anyway. Commented Aug 12, 2024 at 6:22
  • In case you can add custom php.ini for you account, then technically it could be possible. But honestly, I I woudn't do it anyway, for the reason that debugger makes your php extremely slow alone. Commented Aug 14, 2024 at 7:45
  • I don't mind if the development environment is slow while debugging, because this wouldn't affect production. Commented Aug 15, 2024 at 2:34

1 Answer 1

-1

I don't think you can debug using phpdbg on a shared hosting as they usually have high security restrictions... Maybe you could ask them if they provide that service?

The only alternative solution I can think of is the "printf debug style", echoing messages through your app that can give you a hint of what may be going wrong. You can use a service like bcons for that (it has a free-forever plan).

Disclaimer: I'm one of the bcons developers, but this is no self promo, I've successfully used it to find bugs in environments like yours.

Sign up to request clarification or add additional context in comments.

3 Comments

Given debugging on a live server should be a rare exception and by no means a rule, I don't find adding bells and whistles to the process necessary. An error log and tail -f in console would do in emergency. And when not in emergency, you should debug locally.
@YourCommonSense So when everything works fine on your local dev server but not in production and nothing is reported in the error logs or console .. then what?
@Hibish you can still debug without an ide, can't you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.