PHPStorm with remote server on same network plus xdebug

Hi ...

 

I'm new here and I'm new to PHPStorm so please forgive me, if that question was asked before. I couldn't find it though through the search.

 

I have installed PHPStorm on my local machine. The webserver is another machine that I have connected through VPN. Its an IIS on a W2012R2 with xDebug installed.

I would like to edit my sources directly on the server and also being able to use xDebug. I cannot however get it to run at all. It seems that you have to have the webserver on your development system and you need a copy of your sources on your PC as well. Right now I can directly edit the sources on my local machine using a share, but that doesn't help with the debugging. Also my local machine obviously doesn't have php installed, so that fails, too.

Please advise.

Cheers,

Guenter

0
5 comments

Hi there,

First of all -- some links:

 

 

>I would like to edit my sources directly on the server...

>Right now I can directly edit the sources on my local machine using a share,

In general it's not recommended way at all. IDE requires fast access to source files (otherwise you may see random short freezes in the middle of typing a word etc) therefore the recommended way is to have local copy of your files and then setup automatic deployment (so file gets uploaded on Save).

 

Now debugging:

  • There is no need for local PHP or local web server -- PhpStorm can debug remotely executed files
  • But source files must be accessible locally (be it actual local files as recommended or accessible via mapped drive is not so important) for debugger to be able to step in/ place breakpoints etc

 

Considering your current scenario:

  • Ensure that your router/firewall allows incoming connections on xdebug port (yes -- it's xdebug that connects to IDE and not other way around -- often forgotten/misunderstood moment)
  • Ensure that you either use Run/Debug Configuration of correct type .. or just use "Phone handle" icon to start listening for incoming debug connections
  • Make sure that source file can be opened in IDE and that it is a part of the project (ideally local copy; the very max -- mapped drive letter or some sort of symbolic link)
  • The path mappings (the absolute remote path vs local (as seen by IDE)) can be set in "Settings | Languages & Frameworks | PHP | Servers" -- this allows to map remote "C:\websites\domain.com\httpdocs" to locally accessible "Z:\domain.com\httpdocs"
  • NOTE: remote paths must be as seen by xdebug, which works with final/resolved paths (in case if you have symlinks/junction poits there on remote)

Overall I suggest zero-config approach -- will help with path mappings + no need to setup any Run/Debug Configurations.

1

Thanks very much.

Having a local copy and mapping it also to the deployment server is no problem.

I will go through this and will let you know my findings.

 

When setting up the project or at settings/languages/php you can set up the CLI Interpreter.

What's the reason for this? Is it enough to simply copy php on my local system and set the

php.exe in my setup? What advantage am I loosing here?

 

Thanks again!

0

>When setting up the project or at settings/languages/php you can set up the CLI Interpreter. What's the reason for this?

PHP Interpreter is needed if you wish to

  • execute PHP scripts locally (e.g. Run/Debug Configuration of "PHP Script" type)
  • run local PHPUnit tests and alike (that requires local PHP)
  • run other PHP-powered tools (PHPMD/Code Sniffer etc)
  • run built-in web server

>Is it enough to simply copy php on my local system and set the php.exe in my setup?

It depends on your OS -- please refer to php.net for instructions.

But generally speaking -- get PHP from windows.php.net and install needed VS dependencies (links available there as well) and it will run.

0

allright... I thought PHP is needed for the code checking within the IDE. Good to know, it's not.

 

The current status:

 

- I set up the files in my local machine

- I used deployment and path mapping to have the local changes published on my webserver. So when I save the file, it's updating the files on the server automatically. (In Tools/Deployment/Options I've tried the "always" option rather than "On explicit save action) but that made no difference at all).

- I have installed xdebug on the websverer as well as the debug booklets in my browser.

 

Right now the only thing missing is to make sure, that xdebug can reach PHPStorm via network. I'm working on that now.

0

>In Tools/Deployment/Options I've tried the "always" option rather than "On explicit save action) but that made no difference at all).

"Always" meant for automatic save cases (when IDE saves all unsaved files for you automatically: e.g. before running any Run/Debug Configuration, when accepting changes made in Settings screen, when executing terminal command and other cases).

"On explicit save" option for situations when you manually invoke "File | Save All" (Ctrl+S) -- should skip auto save events.

0

Please sign in to leave a comment.