IntelliJ IDEA 2018.2 Help

Configuring Remote PHP Interpreters

In this section:

The term remote PHP interpreter denotes a PHP engine installed on a remote host or in a virtual environment. The term remote PHP interpreter is used as the opposite of local PHP interpreters that are installed on your computer, see Configuring Local PHP Interpreters.

Before you start working with remote interpreters, make sure that the SSH Remote Run plugin is enabled. The plugin is bundled with IntelliJ IDEA and is activated by default. If the plugin is not activated, enable it on the Plugins settings page of the Settings / Preferences Dialog as described in Managing Plugins.

You can access a remote PHP interpreter in any of the following ways:

Using the Vagrant configuration, you can access a Java interpreter installed on the corresponding Vagrant instance.

Before you start:

  1. Make sure that Vagrant and Oracle's VirtualBox are downloaded, installed, and configured on your computer as described in Vagrant.

  2. Make sure the Vagrant and PHP Remote Interpreter plugins are installed and enabled. The plugins are not bundled with IntelliJ IDEA, but they can be installed from the JetBrains plugin repository as described in Managing Plugins. Once enabled, the plugins are available at the IDE level, that is, you can use them in all your IntelliJ IDEA projects.

  3. Make sure that the parent folders of the following executable files are added to the system PATH variable:
    • vagrant.bat or vagrant from your Vagrant installation. This should be done automatically by the Vagrant installer.

    • VBoxManage.exe or VBoxManage from your Oracle's VirtualBox installation.

  4. Configure the PHP development environment in the Vagrant instance to be used.

Learn more about using Vagrant with IntelliJ IDEA in Vagrant.

To configure a PHP interpreter in a Vagrant instance

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | PHP.

  2. On the PHP page that opens, click the browseButton button next to the CLI Interpreter list.

  3. In the CLI Interpreters dialog that opens, click Add icons general add svg in the left-hand pane, then choose From Docker, Vagrant, VM, Remote... on the context menu.

  4. In the Configure Remote PHP Interpreter dialog that opens, choose the Vagrant method.

    Remote interpreter via Vagrant dialog

  5. Provide the connection parameters:
    • Specify the Vagrant instance folder which points at the environment you are going to use. Technically, it is the folder where the VagrantFile configuration file for the desired environment is located. Based on this setting, IntelliJ IDEA detects the Vagrant host and shows it as a link in the Vagrant Host URL read-only field.

      To use an interpreter configuration, you need path mappings that set correspondence between the project folders, the folders on the server to copy project files to, and the URL addresses to access the copied data on the server. IntelliJ IDEA evaluates path mappings from the VagrantFile configuration file.

  6. In the Java interpreter path field, specify the location of the PHP executable file in accordance with the configuration of the selected remote development environment.
    • For Vagrant instances, IntelliJ IDEA by default suggests the /usr/bin/php folder.

    To specify a different folder, click Open and choose the relevant folder in the dialog that opens. Note that the PHP home directory must be open for editing.

    When you click OK, IntelliJ IDEA checks whether the PHP executable is actually stored in the specified folder.
    • If no PHP executable is found, IntelliJ IDEA displays an error message asking you whether to continue searching or save the interpreter configuration anyway.

    • If the PHP executable is found, you return to the Interpreters dialog where the installation folder and the detected version of the PHP interpreter are displayed.

  7. Click Show phpinfo Show phpinfo button to have IntelliJ IDEA display a separate information window with the installation details and the list of loaded extensions and configured options. Please note that the additional options specified in the Configuration Options field of the CLI Interpreters dialog are not listed.

Using the Deployment configuration, you can access a Java interpreter installed on a remote deployment server. This approach is also helpful if you are going to synchronize your project sources with the web server on the target remote host.

Before you start:

  1. Make sure that an ssh server is running on the target remote host and you have configured access to it.

  2. Make sure the PHP Remote Interpreter repository plugin is installed and enabled as described in Managing Plugins.

  3. Make sure the Remote Hosts Access plugin is enabled. The SSH Remote Run plugin is activated by default. If the plugin is disabled, enable it on the Plugins settings page as described in Managing Plugins.

To configure a remote PHP interpreter based on an SFTP server access configuration

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | PHP.

  2. On the PHP page that opens, click the browseButton button next to the CLI Interpreter list.

  3. In the CLI Interpreters dialog that opens, click Add icons general add svg in the left-hand pane, then choose From Docker, Vagrant, VM, Remote... on the context menu.

  4. In the Configure Remote PHP Interpreter dialog that opens, choose the Deployment Configuration method.

    Remote interpreter via Deployment Configuration dialog

  5. Provide the connection parameters:
    • From the Deployment Configuration list, choose the server access configuration of the SFTP type according to which you want IntelliJ IDEA to connect to the target host. If the settings specified in the chosen configuration ensure successful connection, IntelliJ IDEA displays the URL address of the target host as a link in the Deployment Host URL field.

      To use an interpreter configuration, you need path mappings that set correspondence between the project folders, the folders on the server to copy project files to, and the URL addresses to access the copied data on the server. By default, IntelliJ IDEA retrieves path mappings from the chosen server access (deployment) configuration. If the configuration does not contain path mappings, IntelliJ IDEA displays the corresponding error message.

      To fix the problem, open the Deployment page under the Build, Execution, Deployment node, select the relevant server access configuration, switch to the Mappings tab, and map the local folders to the folders on the server as described in the Mapping local folders to folders on the server and the URL addresses to access them section.

  6. In the Java interpreter path field, specify the location of the PHP executable file in accordance with the configuration of the selected remote development environment.
    • For remote hosts, IntelliJ IDEA by default suggests the /usr/bin/php folder.

    To specify a different folder, click Open and choose the relevant folder in the dialog that opens. Note that the PHP home directory must be open for editing.

    When you click OK, IntelliJ IDEA checks whether the PHP executable is actually stored in the specified folder.
    • If no PHP executable is found, IntelliJ IDEA displays an error message asking you whether to continue searching or save the interpreter configuration anyway.

    • If the PHP executable is found, you return to the Interpreters dialog where the installation folder and the detected version of the PHP interpreter are displayed.

  7. Click Show phpinfo Show phpinfo button to have IntelliJ IDEA display a separate information window with the installation details and the list of loaded extensions and configured options. Please note that the additional options specified in the Configuration Options field of the CLI Interpreters dialog are not listed.

Using SSH Credentials, you can access a Java interpreter through the SSH access to the host where the PHP interpreter is installed.

Before you start:

  1. Configure access to an ssh server on the target remote host and make sure this server is running.

  2. Make sure the PHP Remote Interpreter repository plugin is installed and enabled as described in Managing Plugins.

To configure a PHP interpreter using SSH credentials

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | PHP.

  2. On the PHP page that opens, click the browseButton button next to the CLI Interpreter list.

  3. In the CLI Interpreters dialog that opens, click Add icons general add svg in the left-hand pane, then choose From Docker, Vagrant, VM, Remote... on the context menu.

  4. In the Configure Remote PHP Interpreter dialog that opens, choose the SSH Credentials method.

    Remote interpreter via SSH Credentials dialog

  5. Provide the connection parameters:
    • Specify the name of the remote host and the port which the SSH server listens to. The default port number is 22.

    • Specify the remote host access credentials. Type your user name and choose the authentication method:
      • To access the host through a password, choose Password from the Authentication type list, specify the password, and select the Save password checkbox to have IntelliJ IDEA remember it.

      • To use SSH authentication via a key pair, choose Key pair (OpenSSH or PuTTY). To apply this authentication method, you need to have your private key on the client machine and your public key on the remote server you connect to. IntelliJ IDEA supports private keys generated using the OpenSSH utility.

        Specify the path to the file where your private key is stored and type the passphrase (if any) in the corresponding fields. To have IntelliJ IDEA remember the passphrase, select the Save passphrase checkbox.

      • If your SSH keys are managed by a credentials helper application (for example, Pageant on Windows or ssh-agent on Mac and Linux), choose OpenSSH config and authentication agent.

      To use an interpreter configuration, you need path mappings that set correspondence between the project folders, the folders on the server to copy project files to, and the URL addresses to access the copied data on the server. IntelliJ IDEA first attempts to retrieve path mappings itself by processing all the available application-level configurations. If IntelliJ IDEA finds the configurations with the same host as the one specified above, in the Host field, the mappings from these configurations are merged automatically. If no configurations with this host are found, IntelliJ IDEA displays an error message informing you that path mappings are not configured.

      To fix the problem, In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Languages & Frameworks | PHP. Click Open in the Path mappings field and map local folders to the folders on the server.

  6. In the Java interpreter path field, specify the location of the PHP executable file in accordance with the configuration of the selected remote development environment.
    • For remote hosts, IntelliJ IDEA by default suggests the /usr/bin/php folder.

    To specify a different folder, click Open and choose the relevant folder in the dialog that opens. Note that the PHP home directory must be open for editing.

    When you click OK, IntelliJ IDEA checks whether the PHP executable is actually stored in the specified folder.
    • If no PHP executable is found, IntelliJ IDEA displays an error message asking you whether to continue searching or save the interpreter configuration anyway.

    • If the PHP executable is found, you return to the Interpreters dialog where the installation folder and the detected version of the PHP interpreter are displayed.

  7. Click Show phpinfo Show phpinfo button to have IntelliJ IDEA display a separate information window with the installation details and the list of loaded extensions and configured options. Please note that the additional options specified in the Configuration Options field of the CLI Interpreters dialog are not listed.

Using the Docker configuration, you can access a Java interpreter installed in a Docker container.

Before you start:

  1. Make sure that Docker is downloaded, installed, and configured on your computer as described in Docker.

  2. Make sure the Docker Integration, PHP Docker, and PHP Remote Interpreter plugins are installed and enabled. The plugins are not bundled with IntelliJ IDEA, but they can be installed from the JetBrains plugin repository as described in Managing Plugins. Once enabled, the plugins are available at the IDE level, that is, you can use them in all your IntelliJ IDEA projects.

  3. Configure the PHP development environment in the Docker container to be used.

Learn more about using Docker with IntelliJ IDEA in Docker.

To configure a PHP interpreter in a Docker container

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | PHP.

  2. On the PHP page that opens, click the browseButton button next to the CLI Interpreter list.

  3. In the CLI Interpreters dialog that opens, click Add icons general add svg in the left-hand pane, then choose From Docker, Vagrant, VM, Remote... on the context menu.

  4. In the Configure Remote PHP Interpreter dialog that opens, choose the Docker method.

    Remote interpreter via Docker dialog

  5. Provide the connection parameters:
    • In the Server field, specify the Docker configuration to use, see Docker for details. Choose a configuration from the list or click browseButton and create a new configuration in the Docker dialog box that opens.

    • In the Image name field, specify the base Docker image to use. Choose one of the previously downloaded or your custom images from the drop-down list or type the image name manually, for example, php:latest or php:7.0-cli. When you later launch the run configuration, Docker will search for the specified image on your machine. If the search fails, the image will be downloaded from the image repository specified on the Registry page.

  6. In the Java interpreter path field, specify the location of the PHP executable file in accordance with the configuration of the selected remote development environment.
    • For Docker containers, IntelliJ IDEA by default suggests the php folder.

    When you click OK, IntelliJ IDEA checks whether the PHP executable is actually stored in the specified folder.
    • If no PHP executable is found, IntelliJ IDEA displays an error message asking you whether to continue searching or save the interpreter configuration anyway.

    • If the PHP executable is found, you return to the Interpreters dialog where the installation folder and the detected version of the PHP interpreter are displayed.

  7. Click Show phpinfo Show phpinfo button to have IntelliJ IDEA display a separate information window with the installation details and the list of loaded extensions and configured options. Please note that the additional options specified in the Configuration Options field of the CLI Interpreters dialog are not listed.

Using the Docker Compose configuration, you can access a Java interpreter running in a multi-container Docker Compose environment.

Before you start:

  1. Make sure that Docker is downloaded, installed, and configured on your computer as described in Docker.

  2. Make sure the Docker Integration, PHP Docker, and PHP Remote Interpreter plugins are installed and enabled. The plugins are not bundled with IntelliJ IDEA, but they can be installed from the JetBrains plugin repository as described in Managing Plugins. Once enabled, the plugins are available at the IDE level, that is, you can use them in all your IntelliJ IDEA projects.

  3. Configure the PHP development environment in the Docker container to be used.

Learn more about using Docker Compose with IntelliJ IDEA in Using Docker Compose.

To configure a PHP interpreter using Docker Compose

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | PHP.

  2. On the PHP page that opens, click the browseButton button next to the CLI Interpreter list.

  3. In the CLI Interpreters dialog that opens, click Add icons general add svg in the left-hand pane, then choose From Docker, Vagrant, VM, Remote... on the context menu.

  4. In the Configure Remote PHP Interpreter dialog that opens, choose the Docker Compose method.

    ps configure remote interpreter docker compose

  5. Provide the connection parameters:
    • In the Server field, specify the Docker configuration to use, see Docker for details. Choose a configuration from the list or click browseButton and create a new configuration in the Docker dialog box that opens.

    • In the Configuration file(s) field, specify the docker-compose configuration files to use. The base configuration file located in the project root is selected by default. To select a different file or several files, click Open and select the desired configuration file in the Docker Compose Configuration Files dialog that opens.

    • From the Service list, choose the service corresponding to the container the Java development environment is set up in.

    • If necessary, in the Environment Variables field, provide the environment variables. See Using Environment Variables for details.

  6. In the Java interpreter path field, specify the location of the PHP executable file in accordance with the configuration of the selected remote development environment.
    • For Docker containers, IntelliJ IDEA by default suggests the php folder.

    When you click OK, IntelliJ IDEA checks whether the PHP executable is actually stored in the specified folder.
    • If no PHP executable is found, IntelliJ IDEA displays an error message asking you whether to continue searching or save the interpreter configuration anyway.

    • If the PHP executable is found, you return to the Interpreters dialog where the installation folder and the detected version of the PHP interpreter are displayed.

  7. Click Show phpinfo Show phpinfo button to have IntelliJ IDEA display a separate information window with the installation details and the list of loaded extensions and configured options. Please note that the additional options specified in the Configuration Options field of the CLI Interpreters dialog are not listed.

Providing additional configuration options

Optionally, you can customize the configuration settings of the Java installation in the Additional area of the CLI Interpreters dialog.

  • In the Debugger extension field, specify the path to Xdebug. This enables IntelliJ IDEA to activate Xdebug when it is necessary if you have disabled it in the php.ini file, see Configuring Xdebug for Using in the On-Demand Mode.

  • In the Configuration options field, compose a string of configuration directives to be passed through the -d command line option and thus add new entries to the php.ini file. The directives specified in this field override the default directives generated by IntelliJ IDEA, such as -dxdebug.remote_enable=1, -dxdebug.remote_host=127.0.0.1, -dxdebug.remote_port=9001, -dxdebug.remote_mode=req.

    For example, if you specify the -dxdebug.remote_mode=jit directive it will override the default -dxdebug.remote_mode=req directive and thus switch Xdebug to the Just-In-Time (JIT) mode, see Debugging in the Just-In-Time Mode for details.

    To do that, click Browse Open next to the Configuration options field, and then create a list of entries in the Configuration Options dialog that opens.

    • To add a new entry, click the Add button icons general add svg. In the new line, that is added to the list, specify the name of the new entry and its value in the Name and Value text boxes respectively.

      You can add as many entries as you need, just keep in mind that they will be transformed into a command line with its length limited to 256 characters.

    • To delete an entry, select it in the list and click the Remove button icons general remove svg.

    • To change the order of entries, use the Up icons actions previousOccurence svg and Down icons actions nextOccurence svg buttons.

    Upon clicking OK, you return to the CLI Interpreters dialog, where the entries are transformed into a command line.

Configuring custom mappings

If you use an interpreter accessible through SFTP connection or located on a Vagrant instance or in a Docker container, the mappings are automatically retrieved from the corresponding deployment configuration, Vagrantfile, or Dockerfile.

To specify additional mappings:

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Languages & Frameworks | PHP.

  2. From the Interpreter list, choose the remote interpreter for which you want to customize the mappings. The Path Mappings read-only field shows the path mappings retrieved from the corresponding deployment configuration, Vagrantfile, or Dockerfile. To specify the custom mappings, click icons actions menu open svg next to the Path Mappings field.

  3. The Edit Project Path Mappings Dialog that opens, shows the path mappings retrieved from the deployment configuration, Vagrantfile, or Dockerfile. These mappings are read-only.
    • To add a custom mapping, click icons general add svg and specify the path in the project and the corresponding path on the remote runtime environment in the Local Path and Remote Path fields respectively. Type the paths manually or click Open and select the relevant files or folders in the dialog box that opens.

    • To remove a custom mapping, select it in the list and click icons general remove svg.

Last modified: 20 November 2018

See Also

Procedures:

Reference:

Language and Framework-Specific Guidelines: