PHP Extension for VS Code: What to Install
The PHP extension for Visual Studio Code is the official PHP IntelliSense extension published by Microsoft, identifiable by its marketplace ID bmewburn.vscode-intelephense-client (the widely used Intelephense client) or the built-in PHP language support that ships with VS Code. In practice, most developers install the PHP Intelephense extension for full code intelligence, and optionally add PHP Debug for Xdebug integration. Together they turn VS Code into a capable PHP editor.
What the PHP Extension Actually Does
VS Code ships with basic PHP language support out of the box: syntax highlighting, bracket matching, and simple snippet completion. That built-in support does not understand your code. It cannot tell you that $user->getName() exists, cannot jump to a function definition, and cannot flag a misspelled method before you run the script.
The PHP Intelephense extension fills that gap. It is a language server that indexes your project and provides:
- IntelliSense — context-aware completion for classes, methods, functions, constants, and variables.
- Go to Definition and Find All References across files.
- Hover information showing signatures, docblocks, and parameter types.
- Diagnostics — squiggly underlines for undefined symbols, wrong argument counts, and type mismatches.
- Formatting and code actions such as importing namespaces.
- Workspace symbol search to jump to any class or function by name.
Separately, the PHP Debug extension (marketplace ID xdebug.php-debug) connects VS Code's debugger to Xdebug running inside PHP. It lets you set breakpoints, step through code, inspect variables, and evaluate expressions — but it does not provide IntelliSense on its own.
How the Language Server Works
Intelephense runs as a background process. When you open a folder, it scans PHP files and builds an index of symbols, then answers editor requests from that index. The first scan of a large project can take a few seconds; after that, responses are near-instant.
Because the index is built from your files and from stubs for PHP's built-in functions, the extension knows about core functions like array_map and str_contains without any configuration. For framework code — Laravel, Symfony, WordPress — the index picks up classes from vendor/ if that directory is inside the workspace, which is why keeping dependencies installed locally matters for accurate completion.
Intelephense has a free tier and a paid license. The free tier covers the core features most developers need. The paid license unlocks some advanced capabilities, but the extension remains fully usable without purchasing anything.
Installing and Configuring It
- Open VS Code and go to the Extensions view (
Ctrl+Shift+Xon Windows/Linux,Cmd+Shift+Xon macOS). - Search for PHP Intelephense and install the extension by Ben Mewburn.
- Reload the window if prompted.
- Open a folder containing PHP files. The extension indexes automatically.
- Optionally install PHP Debug and configure Xdebug in your
php.ini.
Useful settings live under intelephense.* in settings.json. For example, intelephense.environment.phpVersion tells the extension which PHP version to assume, which affects which built-in functions appear in completion. intelephense.files.maxSize controls how large a file can be before it is skipped. If your project uses a nonstandard stub directory, intelephense.stubs lets you add it.
For debugging, the PHP Debug extension reads a launch.json configuration. A typical setup listens on port 9003 (the default Xdebug port in recent versions) and maps the local workspace path to the server path when debugging inside a container or remote host.
Common Problems and Fixes
- Completion missing for vendor classes. Run
composer installso thevendor/directory exists and is inside the opened folder. Then run the command Intelephense: Index workspace. - False “undefined function” warnings. The extension may not know a framework helper. Add the relevant stub or adjust
intelephense.environment.includePaths. - Slow indexing on huge projects. Exclude generated directories such as
storage/,cache/, or build output viaintelephense.files.exclude. - Debugger never connects. Confirm Xdebug is installed and enabled in
php.ini, thatxdebug.modeincludesdebug, and that the port inlaunch.jsonmatchesxdebug.client_port. - Conflicts with other PHP extensions. Running two language servers for PHP at once can produce duplicate diagnostics. Disable one if you see doubled warnings.
How to Choose Among PHP Extensions
Several PHP-related extensions exist, and they serve different purposes:
- PHP Intelephense — the most popular language server; strong completion and diagnostics.
- PHP Debug — required for step debugging with Xdebug.
- PHP DocBlocker — inserts docblock templates above functions and classes.
- PHP CS Fixer — runs the external PHP CS Fixer tool to reformat code.
- Composer — provides commands and dependency hints for Composer projects.
A practical baseline is Intelephense plus PHP Debug. Add the others only when a specific workflow calls for them; each extra extension adds startup cost and potential overlap.
Costs and Licensing
VS Code itself is free. The PHP Intelephense extension is free to install and use for its core features; a paid license exists for advanced functionality, sold by the extension author. PHP Debug is free and open source. Xdebug, the PHP extension that powers debugging, is free and open source as well. There is no requirement to pay to get a working PHP development environment in VS Code.
Frequently Asked Questions
Is there an official PHP extension from Microsoft?
Microsoft maintains VS Code's built-in PHP language support, which provides syntax highlighting and basic editing features, but the full IntelliSense experience comes from third-party extensions such as Intelephense. Microsoft does not publish a separate full-featured PHP language server extension.
Do I need Xdebug to use PHP in VS Code?
No. Xdebug is only needed for step debugging. Editing, completion, and diagnostics work without it. Install Xdebug when you want breakpoints and variable inspection.
Why does Intelephense show errors for my framework's helper functions?
Helpers defined at runtime or outside the indexed files are unknown to the language server. Adding stubs or include paths for those symbols resolves the false warnings.
Can I use VS Code for PHP without any extensions?
Yes, but you get only basic syntax highlighting and bracket matching. For navigation, completion, and error checking, at least one language server extension is needed.
Does the PHP extension work with remote development?
Yes. When using VS Code Remote or a container, install the extension in the remote environment so it can index the files where they actually live, and configure path mappings for debugging.
Which PHP version should I set in the extension?
Set intelephense.environment.phpVersion to the version your project targets. This ensures completion reflects the functions and syntax available in that version rather than the latest release.