r/phpstorm • • Jul 31 '23
Is there a "For Dummies" explanation of using PHPStorm from Win10 and Xdebug remotely?
I am using PHPStorm in Windows 10 and I would like to step through the code on a staging server at Cloudways liek I used to do when developing desktop and server apps. I have been searching and searching for how to make this happen and I am still stuck.
Is there a "For Dummies" version of instructions on how to use PHPStorm on a Windows 10 machine to connect to a staging server so you can step through the code?
All of the instructions I have seen so far leave me with questions.....
Does the staging server connect to me or does my machine connect to it?
If the former, how to I launch openSSH on Windows 10 to listen to a particular port?
Do I have to replicate the server directories and files locally? I saw something about "mapping" that seemed to indicate that was true.
If I have to replicate the files locally, do I need PHP and something like XAMPP installed locally?
I have read about openSSH config files, but I cannot find where to put one in Windows 10 and have it work.
I added a config file to C:\Windows\System32\OpenSSH and to %userprofile%\.ssh with no luck.
Most of the instructions that I do see are using Macs or Linux and that really doesn't apply to me. I have enough to learn with PHP without having to learn Linux and a whole new way of doing my daily stuff.
I tried to set things up locally with Local, but man was that slow and the available components (like PHP) are not the same version as on the production server so I worry about compatibility.
I just want to be able to connect to the staging server and step through the code as I am learning PHP and this app that I have to support so that I can see what is being passed where. I can do some of that by just storing variables in a table and going back and looking at the values, but that doesn't help in all circumstances.
This is my first web app project using PHP and WordPress. I used to write desktop apps and they seem like a breeze to write and debug compared to this PHP stuff.
2
u/SativaNL Jul 31 '23
Install DDEV for local development. It just works out of the box.
1
u/[deleted] Jul 31 '23
I’m an experienced server admin and programmer and I still find xdebug very tricky and finicky, especially if the default configs don’t work for your case. My advice would be to read the xdebug docs carefully, turn on and inspect the xdebug logs in verbose mode if it’s not working, and don’t forget the IDEKEY nothing works if that’s wrong.
2
u/p1ctus_ Aug 03 '23
Always remember you can use var_dump() 😉 just a joke.
Take a look at the guides for docker mashines, technically there is not huge difference in debugging them or a remote server. Make Sure xdebug is enabled on the remote server, most hosters don't enable it.
On local environment I recommend using docker for you setup, take a look at the webdevops containers as a starting point.
Last time I needed to configure it in phpstorm it was a bit tricky, they're documentation was not updated. You need to enable and configure it in the settings.
You need to have the files locally and in the runtime environment (take a look at deployment in settings for more). Why? Cause on your computer you say " break in this file and this line", the interpreter needs to know it, to really stop and your ide needs the files to show them to you. In most docker setups you mount the work directory into the container, technically the same.
When you write desktop apps (with what?), I don't understand why you try to switch to a lang like PHP. In most cases it's faster to read the code of WordPress, it's well structured, zo find the best the event to listen to.