Order | Area | TOCTitle | ContentId | PageTitle | DateApproved | MetaDescription |
---|---|---|---|---|---|---|
7 |
languages |
PHP |
DD4E5A59-1586-4A5D-8047-3D58B2FE6937 |
PHP Programming with Visual Studio Code |
4/14/2016 |
Learn about Visual Studio Code features (syntax highlighting, snippets, linting) for PHP development. |
Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense, and snippets out of the box and you can add more functionality through community created VS Code extensions.
Visual Studio Code includes a set of common snippets for PHP. To access these, hit kb(editor.action.triggerSuggest)
to get a context specific list.
VS Code uses the official PHP linter (php -l
) for PHP language diagnostics. This allows VS Code to stay current with PHP linter improvements.
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 set the PHP executable path, open your User or Workspace Settings and add the php.validate.executablePath
:
{
"php.validate.executablePath": "c:/php/php.exe"
}
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 by running the Extensions: Install Extension command (kb(workbench.action.showCommands)
and type ext install
) then filter the extensions drop down list by typing php
.
PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension's instructions for configuring XDebug to work with VS Code.
Read on to find out about:
- Extension Marketplace - Browse the extensions others have shared
- Debugging - Learn more about VS Code debugging