Skip to content

PHP Version#

Choose which PHP version the editor uses for code analysis.

The version also specifies what PHP binary will be used for debugging, the built-in server, and test execution. You can also define custom PHP paths for different versions.

PHP Requirements#

PHP Tools Editor does not require php to be installed on the system. Although, for local debugging, testing, and launching the PHP application, php is required.

Choosing PHP Version#

The editor, debugger, and also the test explorer respect and use the configured php version. By default, the global php command is used, if available.

Also, features like code validation and code completion respect the chosen php version in order to provide precise results, and compatibility diagnostics.

PHP Version Picker#

To see what PHP version the editor is using, open a .php file, and check the Visual Studio Code status bar:

php version

Clicking the PHP version number opens the PHP Version Picker:

PHP Version Picker

Composer.Json#

The editor picks the PHP version automatically from the composer.json file if it specifies the php or php-64bit requirement, for example:

{ "require": { "php": ">=8.0.2" } }

PHP Version Setting#

This setting can be modified either using the PHP Version Picker (above) or manually by editing the Visual Studio Code Settings (settings.json), the "php.version" directive:

{
    "php.version": "8.0",
}

The value can be either in format "major.minor", or more specific "major.minor.build". Alternatively, when defining custom PHP paths (below) with an identifier, the setting can refer to a custom identifier, for example:

{
    "php.version": "myphp",
}

Custom PHP paths#

In case PHP is installed in a non-standard custom location, you can specify a custom path so PHP Tools can find and use it.

Open VS Code Settings (File > Preferences > Settings). Switch to the User scope, and look for the php.executables setting:

vscode settings php executables

Edit the php.executables setting:

php executables setting

The php.executables setting contains pairs of "identifier": "php binary path".

The specified identifier can be used by PHP Tools in PHP Version Picker (above), the debug launch configuration, or "php.version" setting in general. The version of PHP is automatically detected, and the editor will adjust to that.