PHP Remote Interpreters Support in PhpStorm 8 EAP
Support for PHP remote interpreters has been introduced in PhpStorm 8 EAP. It lets us use a PHP interpreter over SSH installed on any remote environment, to run/debug application and run testing tools remotely.
Using a remote interpreter instead of a local one gives us an opportunity to get advantages of a PHP interpreter installed in a production-like environment (be it a physical server, a virtualized environment such as Vagrant, or any other). That way we can make sure there will be no inconsistencies when the application is finally deployed to production.
In this blog post we will look into configuring and using PHP remote interpreters for PHPUnit.
PHP Remote Interpreters Configuration
A remote interpreter can be configured in the same way as a local one in Settings | PHP | Interpreter | …
All the current PHP interpreters will be listed. Click the + button to add a new one, then select Remote to add a new remote interpreter.
The PHP remote interpreter dialog displays:
A PHP remote interpreter can be configured:
- Manually – all the SSH connection details should be provided in the dialog (Host, Port, User name, Auth type, Password, etc);
- From the deployment server configuration – after selecting a deployment server, all the connection details will be filled in by PhpStorm from deployment server settings. Please note that SFTP deployment with valid mappings should be configured first in Settings | Deployment to have the button Fill from deployment server settings available.
- From the Vagrant configuration – after selecting Vagrant Configuration Folder, all the connection details will be filled in by PhpStorm from the current Vagrant configuration.
After you click OK, the connection will be tested and (in case of success) the remote interpreter will be added to the list of PHP interpreters in PhpStorm.
Please note that a valid deployment server with correct mappings should be configured in any case so that PhpStorm knows what file should be executed on the remote environment.
PHPUnit via SSH
One of the most important use cases for PHP remote interpreters is running PHPUnit tests remotely, and now it’s already possible.
In order to configure a running PHPUnit remotely, just add a new PHPUnit Setting by Remote Interpreter in Settings | PHP | PHPUnit.
Select the appropriate remote interpreter in the dialog to proceed:
The PHPUnit configuration will be added, and the usual PHPUnit testing workflow will be valid (with PHPUnit configuration through run/debug configurations dialog).
Please note that PHPUnit configuration will be used according to the default PHP interpreter setting for the project. The same PHPUnit configuration can be used for working with local and remote interpreter, it will rely on the default PHP interpreter setting in the project.
Support for PHP remote interpreters is still a work in progress, so please have a look at known and planned issues and take a minute to report any bugs or feature requests to our issue tracker.
Develop with pleasure!
-JetBrains PhpStorm Team