Help with VM and PHPStorm Setup


I'm currently programming on osx 10.8, and run a VM with ubuntu 12.04 Server for execution of code (so that it is run in an identical environment to production). I want to be a good programmer and use a test framework and debugger, but I'm finding the guides for setting up PHPStorm in this environment rather lacking.

How I work: I write code in PHPStorm on OSX, when I save, the file is rsynced to the virtual machine, I run the code on the virtual machine for testing. So the divide is, all editing tools on OSX, and all execution tools on the VM (php, apache, php-cli, etc.).

I'm running into a lot of problems all around the "How do I get phpstorm to point at something on the VM?" question. So to setup Xdebug and PHPUnit, can I install them on the VM alone and have PHPStorm run them remotely? There's not a lot of clear online documentation for this kind of setup. :(

Comment actions Permalink

Hi Jorm,

Your scenario/setup is noting special -- lots of folks using it.

So to setup Xdebug and PHPUnit, can I install them on the VM alone and have PHPStorm run them remotely?

Yes, you can. You just have to keep in mind that:

  1. You have to use "PHPUnit on Server" Run/Debug configuration type when runing your PHPUnit tests:
  2. Such PHPUnit tests will be executed via web interface and not via command line/SSH shell (plus, depending on your Linux distro/configuration, web server (e.g. Apache) may use completely different php.ini config file).

When configuring xdebug -- one of the most important parts is to set correct IP for xdebug.remote_host -- it has to be IP of your physical machine as it seen from VM -- quite a lot of forum threads here with "remote debug does not work" subject getting resolved when correct IP is set (in addition to "I think I have xdebug already installed and configured" but in reality it is not). The easiest way to finding out correct IP is to check value of $_SERVER["REMOTE_ADDR"].

Some useful links:

Comment actions Permalink

Thanks for your help Andriy, all your posts on this forum have been very helpful.

With that said, in trying to configure PHPUnit, I realized that I don't have the basic settings of remote editing / a remote server in place to get PHPUnit working. So I posted a new question, that's backing up a little bit to try and get this sorted out.


Please sign in to leave a comment.