Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense [code completion], and snippets out of the box and you can add more functionality through community-created VS Code extensions.
Linting
VS Code uses the official PHP linter [php -l
] for PHP language
diagnostics. This allows VS Code to stay current with PHP linter improvements.
Tip: Using XAMPP? Install the full version of PHP in order to obtain the development libraries.
There are three settings to control the PHP linter:
php.validate.enable
: controls whether to enable PHP linting at all. Enabled by default.php.validate.executablePath
: points to the PHP executable on disk. Set this if the PHP executable is not on the system path.php.validate.run
: controls whether the validation is triggered on save [value:"onSave"
] or on type [value:"onType"
]. Default is on save.
To change the PHP settings, open your User or Workspace Settings [⌘, [Windows, Linux Ctrl+,]] and type 'php' to filter the list of available settings.
To set the PHP executable path, select the Edit in settings.json link under PHP > Validate: Executable Path, which will open your user settings.json
file. Add the php.validate.executablePath
setting with the path to your PHP installation:
Windows
{
"php.validate.executablePath": "c:/php/php.exe"
}
Linux and macOS
{
"php.validate.executablePath": "/usr/bin/php"
}
Snippets
Visual Studio Code includes a set of common snippets for PHP. To access these, hit ⌃Space [Windows, Linux Ctrl+Space] to get a context-specific list.
PHP extensions
There are many PHP language extensions available on the VS Code Marketplace and more are being created. You can search for PHP extensions from within VS Code in the Extensions view [⇧⌘X [Windows, Linux Ctrl+Shift+X]] then filter the extensions dropdown list by typing 'php'.
Disable built-in PHP support
To disable the built-in PHP smart completions in favor of suggestions from an installed PHP extension, uncheck PHP > Suggest: Basic, which sets php.suggest.basic
to false in your settings.json
file.
Debugging
PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension's instructions for configuring XDebug to work with VS Code.
Next steps
Read on to find out about:
- Extension Marketplace - Browse the extensions others have shared
- Debugging - Learn more about VS Code debugging
9/1/2022
Basic Installation
You will need to have Microsoft Visual Studio installed before installing PHP Tools. You can download the free Community version here or use any other Visual Studio version, except for Express versions, which are not supported.
If you already have Microsoft Visual Studio installed, you can jump directly to the Manage Extensions dialog and search for PHP Tools for Visual Studio.
Once downloaded, you'll be prompted to close Visual Studio. The package will be installed and Visual Studio configured for the PHP development. After starting Visual Studio next time, you can proceed to the product activation and get started.
If you would like more detailed steps, please, continue reading.
Prerequisites
To install PHP Tools for Visual Studio, you'll need:
Administrator access. Please ensure you can provide administrator access to your hard drive because the installation package copies files to the system's AppData. For Visual Studio 2010 up to 2015, you'll be queried to allow access to the system's Program Files*.
Microsoft Visual Studio. Install Microsoft Visual Studio. You can choose the Community edition, which is the free** option, or any other Visual Studio´s supported editions, such as Professional, Enterprise or higher. Express editions are not supported.
Download and Installation
PHP Tools installation package can be downloaded from:
Visual Studio Marketplace - Choose PHP Tools edition according to the version of your Visual Studio.
DEVSENSE.com - You can download any version or any update of PHP Tools for Visual Studio directly from our WebSite.
Instructions for Installation
- Close Visual Studio
- Run the installation package downloaded from any of the locations above
- Follow the instructions on the screen.
- Restart Visual Studio.
The software's installation package can also be used for an Offline Activation.
Activation
The product contains both a 30-day trial and a full product. When the trial is over, you can activate the software using a purchased license key. Please see Product Activation for more details.
Updates
PHP Tools updates are checked automatically. Visual Studio will notify you about updates available. Please see Update Instructions for more information.
Troubleshooting
PHP Tools cannot be found on VS Marketplace
The most probable cause is that you are running an older Visual Studio version. Please update to the latest VS version.
In Visual Studio, go to Help
, and click Check for Updates
. Then in Visual Studio Installer, click on Update
.
VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
If you see this message in the VSIX Installer log, it usually means you will need to update your Visual Studio.
You can see which VS version is a minimal supported version in the VSIX Installer log. There is a section specifying the supported VS version range:
26-7-2022 11:33:05 - Supported Products :
26-7-2022 11:33:05 - Microsoft.VisualStudio.Community
26-7-2022 11:33:05 - Version : [16.10,17.0]
In this case, the lowest supported version is 16.10
.
To see which Visual Studio version are you running, go to Help
, and click About Microsoft Visual Studio
:
If you see a version higher than the one from the VSIX Installer log, then please contact us at .
Otherwise please update your Visual Studio by opening Help
menu and clicking Check for Updates
. Then in Visual Studio Installer, click on Update
.