PHP Editors And IDEs: PhpStorm And VS Code
A PHP editor should help you navigate code, understand types, run project commands, and debug real execution. It should not create a private development environment that disagrees with the terminal or CI.
PhpStorm provides an integrated PHP IDE. Visual Studio Code is a general editor that gains deeper PHP support through extensions. Either can support professional PHP work when it uses the project's actual interpreter and committed tooling.
Configure The PHP Interpreter First
Before evaluating completion or debugging, confirm which PHP executable the editor uses.
php --version
php --ini
php -m
Compare that output with the project's required PHP version and extensions. If the application runs in a container or remote environment, configure that interpreter rather than silently using a different host installation.
In PhpStorm, select a local or remote CLI interpreter in the PHP settings. The selected interpreter also affects test frameworks, quality tools, run configurations, and terminal commands that use the project default.
VS Code uses the official PHP linter for basic diagnostics. If PHP is not on the editor's path, a workspace setting can point to it:
{
"php.validate.enable": true,
"php.validate.executablePath": "/usr/bin/php",
"php.validate.run": "onSave"
}
Do not commit a machine-specific executable path unless the team shares that path. User settings are often better for local installations; workspace settings are useful for genuinely shared project behavior.
PhpStorm Workflow
PhpStorm includes PHP-aware navigation, completion, refactoring, Composer support, test runners, database tools, quality-tool integration, and Xdebug support.
A useful setup checks:
- the correct local, container, or remote PHP interpreter
- the project's Composer executable and
composer.json - the configured PHPUnit or Pest command
- PHPStan, Psalm, PHPCS, PHP-CS-Fixer, or other tools already used by the repository
- the project's coding style rather than a personal formatter profile
- Xdebug port and server path mappings
Built-in integration is not permission to bypass project commands. If CI runs composer check, run that command before opening a pull request even when the IDE shows no warnings.
VS Code Workflow And Extensions
VS Code includes PHP syntax highlighting, basic completion, snippets, and php -l validation. Extensions can add deeper language intelligence and debugging.
Common capabilities to add include:
- a PHP language server for workspace completion, symbol navigation, references, rename support, and richer diagnostics
- the PHP Debug extension for Xdebug
- integrations for the formatter, analyser, and test runner chosen by the project
- support for containers or remote development when PHP does not run on the host
Intelephense is one widely used PHP language-server extension. It provides code intelligence, navigation, diagnostics, formatting, and PHPDoc support. Avoid running several competing language servers or formatters at once; duplicate diagnostics and conflicting edits make the editor unreliable.
Review an extension's publisher, maintenance status, permissions, license, workspace-trust behavior, and project fit before installation. An extension is executable software, not merely a color theme.
Keep Project Tools Authoritative
Editor diagnostics are fast feedback. The committed configuration remains authoritative.
Examples include:
phpstan.neon
psalm.xml
phpcs.xml
.php-cs-fixer.php
phpunit.xml
composer.json
Configure the editor to call these project-local tools from vendor/bin or through Composer scripts. A globally installed analyser may be a different version and may ignore repository plugins or configuration.
Use editor auto-fix carefully. Review the diff after formatting, imports, refactors, or generated methods, and run the same checks CI runs.
Configure Xdebug Deliberately
Xdebug and the editor communicate over the DBGp protocol. Xdebug normally initiates the connection to a listening editor, using port 9003 by default in Xdebug 3.
For either editor, verify:
- Xdebug is loaded by the PHP runtime handling the request
xdebug.modeincludesdebug- the editor is listening on the configured port
- firewall and container networking allow the connection
- server paths map to the matching local workspace paths
- the breakpoint is on executable code
PhpStorm has built-in Xdebug integration. VS Code uses a PHP Debug adapter extension. Both still depend on correct runtime configuration.
Containers And Path Mappings
A container may execute /var/www/html/src/Order.php while the editor opened /home/dev/project/src/Order.php. The debugger must know those paths refer to the same file.
Path mappings translate runtime paths to workspace paths. Incorrect mappings cause hollow breakpoints, files opening outside the project, or execution that never stops where expected.
Also confirm whether tests and Composer commands should run on the host or inside the container. Mixing environments can use different PHP versions, extensions, environment variables, or filesystem permissions.
A Minimum Professional Setup
A reliable setup lets you:
- identify the PHP binary and loaded
php.ini - navigate to definitions and find references
- run the repository's Composer scripts and tests
- see formatter and analyser feedback from project configuration
- place a breakpoint and inspect a real request or CLI command
- review all automated edits in Git
Keyboard shortcuts and visual preferences come later. Correct execution context matters first.
What To Remember
PhpStorm is an integrated PHP IDE, while VS Code assembles PHP capabilities through built-in support and extensions. Both are effective when they use the same PHP runtime, dependencies, configuration, and commands as the project.
Before moving on, make sure you can identify the editor's PHP executable, explain why project-local tools beat global versions, and diagnose a breakpoint failure caused by path mapping rather than application logic.
Practice
Task: Diagnose A Mismatched Editor Setup
A project requires PHP 8.5 and runs through a container. CI passes, but a developer's editor reports syntax errors for supported PHP features, the integrated test button uses PHP 8.2, and Xdebug breakpoints remain hollow.
Write a diagnosis and correction checklist that covers:
- the PHP interpreter selected by the editor
- host versus container command execution
- the project-local Composer dependencies and quality-tool configuration
- the Xdebug port and listener
- runtime-to-workspace path mappings
- one terminal command that proves the active PHP version
- one command that proves which
php.inifiles are loaded - final verification using the same command as CI
The checklist must work conceptually for either PhpStorm or VS Code.
Show solution
First run php --version and php --ini in the same environment that executes the project. If the application runs in a container, configure the editor's remote or container interpreter and run Composer, tests, and quality tools there rather than through the host PHP 8.2 binary.
Confirm the editor uses project-local dependencies from vendor/bin or the repository's Composer scripts. Reload the workspace after correcting the interpreter so language-level diagnostics use PHP 8.5.
For debugging, verify Xdebug is loaded in the container, xdebug.mode includes debug, Xdebug connects to the editor's listening port, normally 9003, and the debugger maps the container source root to the local workspace root. Then set a breakpoint on executable code and trigger the same request again.
Finish by running the repository's CI-equivalent command, such as composer check, in the container. Editor warnings are useful feedback, but the shared project command proves the corrected setup matches the team environment.