Remote PHP Interpreter vs. Local in PHPStorm: Which Setup Wins When
AI generated
IDE
{ }
PHPStorm · PHP Interpreter · Docker · SSH · Remote
Remote PHP Interpreter vs. Local
Which Setup Wins When

PHPStorm supports three interpreter types: local, Docker/Docker Compose, and SSH. The choice has a direct impact on autocomplete quality, Xdebug reliability, and the overhead of starting run configurations. This article explains the differences and shows when which setup truly wins.

15 min read Local · Docker Compose · SSH · WSL · Remote PHPStorm 2024+ · PHP 8.4 · Docker · Magento 2.4

1. What the PHP interpreter in PHPStorm actually does

The configured PHP interpreter in PHPStorm is not just responsible for running PHP code directly. It is the foundation for several core IDE features: detecting installed extensions (which affect autocomplete and code inspection), resolving PHP version features, running Composer commands through the IDE, starting PHPUnit runs, and connecting to Xdebug. If the interpreter is misconfigured, all of these features are either broken or completely inactive.

PHPStorm fundamentally distinguishes between three interpreter categories: local (a PHP binary on the developer machine), remote via Docker or Docker Compose (PHP runs in a container), and remote via SSH (PHP runs on a remote server). Each category has specific pros and cons that depend on the project structure. In modern Docker-based projects like Magento 2 with a Mark Shust setup, the answer is usually clear: Docker Compose interpreter.

2. Local interpreter: strengths and limits

A local PHP interpreter is the fastest approach: no containers, no connection setup delay, no network overhead. PHPStorm can communicate immediately with the locally installed PHP. That is ideal for simple PHP projects without specific system requirements, for global Composer tools, or for developers on macOS or Linux who have a local PHP that is identical to the production environment.

The limits of the local interpreter show up immediately in container projects. If the project needs PHP 8.4 with specific extensions like sodium, gd, or Magento-specific configurations, the local PHP must have exactly this configuration, otherwise PHPStorm gives wrong autocomplete hints and misses extension-specific functions. Even more critical: if the deployment PHP is a different version than the local PHP, type-error-free local PHPStan analyses lead to PHP errors in production.


<?php
// Example: extension mismatch between local and container PHP

declare(strict_types=1);

// Local: PHP 8.2 without the sodium extension
// Container: PHP 8.4 with sodium

// PHPStorm with the local interpreter flags sodium_crypto_box() as
// "undefined function" even though it exists in the container

// With the Docker Compose interpreter: PHPStorm sees all extensions
// of the container and correctly flags sodium_crypto_box() as present

$ciphertext = sodium_crypto_box(
    message: 'Hello Magento',
    nonce: random_bytes(SODIUM_CRYPTO_BOX_NONCEBYTES),
    key_pair: sodium_crypto_box_keypair()
);

// Autocomplete quality depends directly on the interpreter

3. Docker Compose interpreter: the best setup for Docker projects

For Docker-based projects, the Docker Compose interpreter is the superior choice. When connecting, PHPStorm starts a temporary container (or uses the running phpfpm container) and reads directly from the container: PHP version, installed extensions, php.ini configuration, and Composer packages. Autocomplete and type inference are then based on the actual runtime PHP.

Configuration in PHPStorm: Settings → PHP → CLI Interpreters → + → From Docker, Vagrant, VM, WSL, Remote. Server: Docker Compose. Configuration file: the project's main compose.yaml. Service: phpfpm (or whatever the PHP service is named in the project). PHPStorm then automatically determines the PHP path in the container. The only overhead compared to the local interpreter: PHPStorm needs a brief moment on the first connection to load container information. After that, everything runs transparently.


<?php
// PHPStorm Docker Compose interpreter setup
// Settings → PHP → CLI Interpreters

/*
Interpreter configuration (example for a Mark Shust setup):
- Name: Docker PHP 8.4 (mironsoft)
- Server: Docker Compose
- Configuration files: ./compose.yaml; ./compose.dev-linux.yaml
- Service: phpfpm
- PHP executable: (auto-detected: /usr/local/bin/php)
- Debugger: Xdebug 3.x (auto-detected)

Path Mappings:
- Local:     /home/mir/development/mironsoft/src
- Container: /var/www/html
*/

declare(strict_types=1);

// With this interpreter, PHPStorm recognizes:
// - PHP 8.4 features (property hooks, asymmetric visibility)
// - All container extensions (sodium, gd, imagick, redis, etc.)
// - Composer packages from /var/www/html/vendor/
// - Magento-specific classes and interfaces from vendor/magento/

// Correct autocompletion for PHP 8.4 property hooks:
class Product
{
    public string $name {
        get => strtoupper($this->name);
        set => $this->name = trim($value);
    }
}

4. SSH interpreter: for remote servers and CI scenarios

The SSH interpreter connects PHPStorm to a PHP that runs on a remote server. That makes sense for staging environments accessed by multiple developers, or for scenarios where the development server is run centrally for hardware or licensing reasons. The SSH interpreter uses SFTP for file transfer and executes PHP commands remotely.

Setup: Settings → PHP → CLI Interpreters → + → SSH Credentials. Configure the SSH connection, username, and key file, then specify the path to the PHP binary on the server. The downside of the SSH interpreter compared to Docker Compose: every PHP execution (autocomplete resolution, PHPUnit run) goes over the network. That is barely noticeable with a good connection, but noticeable with slow or unstable connections. For daily development on your own machine, Docker Compose is the better choice.

5. WSL interpreter on Windows

On Windows, PHPStorm has offered native WSL2 support since version 2021.2. From PHPStorm's perspective, the WSL interpreter behaves like a local interpreter but runs inside a Windows Subsystem for Linux container. That is a clean alternative to Docker Compose interpreters on Windows when Docker Desktop has performance issues. The overhead is lower than with Docker Compose, but the isolation is also weaker.

For teams that develop across a mix of Windows and macOS/Linux, the Docker Compose interpreter is still recommended despite WSL support, because it can be configured platform-independently and uses the same PHP as every other team member. A WSL interpreter elegantly solves Windows-specific problems but creates a special case in the team configuration that needs to be documented.


<?php
// WSL interpreter vs. Docker Compose, a decision guide
// (structured as a PHPDoc comment, not executable code)

/*
 * LOCAL INTERPRETER
 * When it makes sense:
 * - Simple PHP project without specific extension requirements
 * - Global Composer tools (phpstan, phpcs standalone)
 * - No Docker environment available
 *
 * When it is problematic:
 * - Docker project with a deviating container PHP
 * - Magento 2 with extension-specific functions
 *
 * DOCKER COMPOSE INTERPRETER
 * When it makes sense:
 * - All Docker-based projects (standard for Magento 2)
 * - Multiple PHP projects with different PHP versions
 * - When Xdebug and PHPUnit should run from the container
 *
 * SSH INTERPRETER
 * When it makes sense:
 * - Development on a central remote server
 * - Staging environments for inspection
 * - When no Docker is available locally
 *
 * WSL INTERPRETER (Windows)
 * When it makes sense:
 * - Windows developers with Docker Desktop performance issues
 * - Only when Docker Compose does not work
 */

6. Path mappings: the critical point of every remote interpreter

With every remote interpreter, whether Docker Compose, SSH, or WSL, path mappings are the most common source of errors. PHPStorm needs to know that a local path on the developer machine corresponds to a path inside the container or on the remote server. Without correct mappings, PHPStorm does not open a local file at an Xdebug breakpoint but shows an error instead. PHPUnit runs cannot map errors to local file lines.

Correct configuration of path mappings: in the interpreter dialog under Path Mappings, map the local project directory (e.g. /home/mir/development/mironsoft/src) to the container path (/var/www/html). For Magento projects with a Mark Shust setup, the container path is /var/www/html by default. In addition, path mappings under Settings → PHP → Servers are required for the Xdebug server. Both places need to be consistent.

7. Xdebug differences between interpreter types

Xdebug behaves differently depending on the interpreter type. With the local interpreter, Xdebug is simple: PHPStorm and PHP run on the same machine, no network configuration needed. With the Docker Compose interpreter, Xdebug inside the container needs to find its way back to the IDE on the host. This is the point where, on Linux, host.docker.internal needs to be configured via extra_hosts: host.docker.internal:host-gateway in the compose file.

With the SSH interpreter, Xdebug is the most complex: the server needs to be able to establish a connection back to the development machine, which is blocked by firewalls in many networks. The alternative: set up an SSH tunnel and configure Xdebug to use it. For daily development that is too much effort, Docker Compose remains the most reliable Xdebug environment. The SSH interpreter is suitable for staging debugging in controlled networks.

8. Direct comparison: local vs. Docker Compose vs. SSH

Criterion Local Docker Compose SSH
Autocomplete quality Depends on local PHP Exactly like container PHP Exactly like remote PHP
Xdebug setup Trivial Requires host-gateway config SSH tunnel needed
Startup overhead None Short container start SSH connection setup
Fit for Docker projects Not recommended Optimal Possible, but complex
Team consistency Depends on local setup Identical for everyone Identical (central server)

9. Summary

Choosing the PHP interpreter in PHPStorm is not a minor detail, it determines the quality of autocomplete, the reliability of Xdebug, and the correctness of PHPStan analyses. For Docker-based projects like Magento 2 with a Mark Shust setup, the Docker Compose interpreter is the right choice: it is based on the actual container PHP and can be configured consistently for the whole team. The local interpreter only fits simple PHP projects without specific extension requirements. SSH interpreters make sense for remote staging scenarios, but are too much effort for daily development.

Remote PHP Interpreter vs. Local: The Key Takeaways

Docker Compose = default

For all Docker-based projects. Settings → PHP → CLI Interpreter → From Docker → Docker Compose → Service: phpfpm.

Path mappings = mandatory

Local to container path in the interpreter dialog AND in Settings → PHP → Servers. Both places need to be consistent.

Local interpreter

Only when there is no Docker and no remote environment. PHP version and extensions must exactly match the production environment.

SSH interpreter

For remote servers and staging. Xdebug needs an SSH tunnel. Not recommended for daily development when Docker is available.

10. FAQ: Remote PHP Interpreter vs. Local in PHPStorm

1When does the local interpreter make sense?
When no Docker is used and the local PHP matches the production environment exactly. Not recommended for Docker projects like Magento 2.
2How to configure the Docker Compose interpreter?
Settings → PHP → CLI Interpreters → + → From Docker → Docker Compose → Service: phpfpm. PHPStorm determines the PHP path and extensions automatically.
3What are path mappings?
Mapping local to container path. Mandatory for Xdebug and PHPUnit. Configure both places: interpreter dialog and Settings → PHP → Servers.
4Xdebug not reachable with Docker on Linux?
extra_hosts: host.docker.internal:host-gateway in compose.yaml. Then set xdebug.client_host=host.docker.internal in the ini.
5Can multiple interpreters be configured at once?
Yes. PHPStorm allows any number of interpreters. One default is set per project, and run configurations can use different interpreters.
6When to use the SSH interpreter?
For staging servers or when no Docker is available. Less suited for daily development, Xdebug needs an SSH tunnel and there is network overhead.
7Reconfigure the interpreter after a Docker image update?
Usually not. For a new PHP version or extension: manual refresh via Settings → PHP → CLI Interpreters → Refresh icon.
8Wrong interpreter for PHPUnit, what happens?
PHPUnit runs on the wrong PHP. Either a PHP version error, or tests run on a deviating PHP. Docker Compose interpreter: tests run identical to the real test environment.
9Does the interpreter type affect autocomplete quality?
Directly. PHPStorm uses the interpreter for extensions, PHP features, and builtins. Wrong interpreter means missing autocomplete for container extensions.
10Does the Docker Compose interpreter work without a running container?
Autocomplete from cache still works. New runs and Xdebug sessions are not possible. Indexing is independent of interpreter status.