Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Using a remote PHP interpreter instead of a local one, lets us run our application and PHP-based tools on a production-like environment, be it the real production server or a virtualized one using tools like Vagrant. Speaking of Vagrant, using remote PHP interpreters we couldinstall only PhpStorm on our development machine and run, debug and unit test our application on the Vagrant machine. In this tutorial, we'll see how we can work with remote PHP interpreters in PhpStorm.

1. Registering a new PHP interpreter

A remote interpreter can be configured in a similar way as local ones. Through Project Settings | PHP, the PHP interpreter we want to use during development can be specified. This can be a local PHP installation, as well as a remote PHP executable. Clicking ... next to the selected interpreter will open a list of registered PHP interpreters. Click the green + to add a new Remote....

 Adding a remote PHP interpreter over SSH...

When using a remote server, enter the SSH connection details to the host. Note that password authentication as well as an OpenSSH or Putty key pair is supported for authentication.

 Adding a remote PHP interpreter from Vagrant...

When using Vagrant support in PhpStorm, we can tick the Vagrant option to automatically populate connection details. In most cases, PhpStorm can also figure out the path to the PHP interpreter on the Vagrant machine. If not, we can adjust it manually.

 Adding a remote PHP interpreter from deployment configuration...

When one or more deployment configurations are present, for example when using Deployments in PhpStorm, the IDE will offer a third option: we can tick the Deployment configuration option to use an existing configuration to connect to a remote PHP interpreter.

2. Selecting the remote PHP interpreter for the current PhpStorm project

Once a remote PHP interpreter has been registered and configured, we can set up our project to use it during development. Simply select it in the dropdown in Project Settings | PHP.

Once configured, all our Run/Debug configurations will make use of the configured PHP interpreter. Since we just configured a remote PHP interpreter as the one that should be used for our project, the following run configuration will always run on the remote server or Vagrant machine.

3. Using the remote PHP interpreter

Once configured, we can start using our remote PHP interpreter, for example for unit testing. Check the Running PHPUnit tests over SSH on a remote server with PhpStorm tutorial for more information.

(optional) Composer and Remote PHP Interpreters

The PHP interpreter is a project setting in PhpStorm: it will be used for all actions that require the PHP executable, for example for running the various Composer commands. When a remote PHP interpreter is configured, the Composer Support in PhpStorm may break because the remote PHP interpreter will potentially not have access to the project path on our development machine.

Through Project Settings | PHP | Composer, we can specify the PHP interpreter to use for running Composer commands.

Once configured, PhpStorm will use the remote PHP interpreter for commands that can be run remote, for example running PHPUnit tests, and a local interpreter for Composer.

  • No labels