Installing PHP Intelephense in Visual Studio Code
This guide explains how to install the PHP Intelephense extension in Visual Studio Code (VSCode).
What is PHP Intelephense?
PHP Intelephense is an extension for Visual Studio Code that provides essential PHP development features such as code completion, go to definition, and more.
Environment
- Windows 10 64-bit
- Visual Studio Code 1.87.2
- PHP 8.2.15
Installation Steps
- Install PHP Intelephense
- Configure Basic PHP Intelephense Settings
- Apply Additional PHP Intelephense Settings
1. Install PHP Intelephense
Open Visual Studio Code, and click on the Extensions icon.
Type php intelephense
in the search bar, and install the “PHP Intelephense” extension from the search results.
PHP Intelephense is now installed.
2. Configure Basic PHP Intelephense Settings
Follow the official Quick Start guide to configure the extension.
Here are the two main steps (license key input is required for premium features, but we’ll skip that in this guide):
- Disable the built-in PHP language features
- Add Non-standard PHP File Extensions to files.associations
1. Disable the built-in PHP language features
To avoid conflicts, disable the built-in PHP language features in VSCode.
Click on the Extensions icon in VSCode.
In the search bar, type @builtin php
, and click on “PHP Language Features” in the search results.
Click “Disable”.
The built-in PHP language features are now disabled.
Note: You can leave “PHP Basic Language Support” enabled.
2. Add Non-standard PHP File Extensions to files.associations
Add non-standard PHP file extensions (such as .module
) to the files.associations
setting.
We’ll follow the official example and add .module
.
Click the gear icon in the bottom left of VSCode, then click “Settings”.
In the Workspace tab, type files.associations
into the search bar.
Click “Add Item” under the Files Associations section.
For Item, enter *.module
.
For Value, enter php
.
Click OK.
Now .module
files will be recognized as PHP.
3. Apply Additional PHP Intelephense Settings
Aside from the Quick Start setup, you can apply additional configuration.
Set your PHP version in the intelephense.environment.phpVersion
setting.
This allows Intelephense to tailor suggestions and diagnostics to your version of PHP.
Open Settings in VSCode, and in the Workspace tab, search for intelephense.environment.phpVersion
.
Set the value to match your PHP version.
For example, if you’re using PHP 8.2, enter 8.2
.
PHP Intelephense is now fully configured.