Vscode Php

Sep 12, 2020 Go to extension market place and search for PHP Debug then click install the PHP Debug (Felix Becker) extension. Reload VSCode window after installation. Then open your php.ini file and paste the following right after the zendextension. 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. PHP Intelephense. This is the must have extension for PHP development and goes a long way to. Summary Xdebug installed: 2.7.0beta1 Server API: Command Line Interface Windows: yes - Compiler: MS VC 15 - Architecture: x64 Zend Server: no PHP Version: 7.3.1 Zend API nr: 320180731 PHP API nr: 20180731 Debug Build: no Thread Safe Build: no OPcache Loaded: no Configuration File Path: C:WINDOWS Configuration File: C:Program Files (x86)phpphp.ini Extensions directory: ext. This linter plugin for Visual Studio Code provides an interface to phpcs.It will be used with files that have the “PHP” language mode. Visual Studio Code must be installed in order to use this plugin.

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.

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 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.

Tip: The extensions shown above are dynamically queried. Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.

Tip: The following setting allows to disable the built-in PHP completions in favor of proposals created by installed PHP extensions.

  • php.suggest.basic: Configures if the built-in PHP language suggestions are enabled. Enabled by default.


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.

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 set the PHP executable path, open your User or Workspace Settings and add the php.validate.executablePath:


Linux and macOS


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

Visual Studio Code is hot stuff right now and is quickly becoming the editor of choice for developers worldwide. It’s available for Mac, Windows and Linux and best of all it’s free.

Personally I was a little skeptical when I first learnt of Microsoft’s latest editor. I have been a long time user of Sublime Text, but VS Code has gradually won me over. The automation it offers with code completion as well as it’s superb git and debugging integration is a real winner. You can even trigger a terminal directly from within VS Code which is great for when you need to do something on the command-line without breaking out of the editor; I find this really helps with my workflow.

A few years ago I wrote about the Sublime Text plugins I considered essential for PHP developers. Now that I am increasingly choosing to load up VS Code instead I thought it was time to share my essential Visual Studio Code extensions for PHP developers. So here are my favourite extensions for improving productivity when writing PHP code.

PHP Intelephense

This is the must have extension for PHP development and goes a long way to making Visual Studio Code feel more like a traditional IDE. PHP Intelephense will massively improve your efficiency by offering intelligent code completion, workspace wide definition support, parameter help for function calls and a whole lot more.

I’ve been using this extension for a while now and have been really impressed by what it offers. It is very rapid. At the time of writing it has an impressive 5 out of 5 rating. If you don’t install any other extension from this post, at least make sure you add this one to your editor.

PHP Mess Detector

This extension is a great way of monitoring your code and trying to keep it lean and bug free. PHP Mess Detector will analyse your code as you type and flag potential bugs and unused code. It will also help you identify overcomplicated expressions and suboptimal code. Unlike some of the following extensions there is no need to install anything extra as long as you have PHP installed, but you can easily customise the rules it runs. It also supports custom rules.


Well written code should use a consistent coding standard, i.e. type of indentation, naming conventions, use of whitespace, bracket placement, etc.. Whatever standard you are working to, phpcs will help you to conform to them. To use this extension you’ll also need to ensure you’ve got PHP CodeSniffer installed; this can be easily done using Composer:-

If you work with more than one coding standard between projects then you’ll want to configure each workspace with the relevant standard. This is easily done by setting phpcs.standard in your workspace’s settings.

PHP CS Fixer

So following on from phpcs, if we’re conforming to some coding standards it can also be useful to be able to quickly fix the formatting of code. That’s where PHP CS Fixer comes in handy. This provides a command that can be run to fix any breaches in standards which can also be switched on to automatically run on save. Like phpcs you will need to have PHP CS Fixer installed on your machine in addition to this Code extension.


This next one may seem a little similar to phpcs, but seeing as many open source projects use this I feel it is well worth having installed too. EditorConfig provides a way of maintaining some coding style consistency between different editors and IDEs. This is particularly valuable when collaborating with others, some of whom may not be using Visual Studio Code to code with.

To use EditorConfig an .editorconfig file is placed in the root of a project and usually committed to the project’s repository so everyone working on it conforms to the rules. This is useful for defining tab styles and line endings among other things. Most editors have plugins available to support EditorConfig including Atom, PhpStorm, Sublime Text and now Visual Studio Code.

You can find out more about EditorConfig and what you can define in the .editorconfig file over on the official website. Details of the Visual Studio Code EditorConfig extension can be found on the Visual Studio Marketplace.

PHP DocBlocker

Good code should be well documented. PHPDoc is a pretty much universally accepted means of doing this in PHP; although many developers find documenting their code tedious. PHP DocBlocker simplifies the process of adding docblock comments by autocompleting /** by pressing Enter or tab taking away some of the pain. This extension really helps by partially automating the process of documenting your functions.

Better PHPUnit

I’m an advocate for testing code. I’ve spoken on the topic twice this year at user groups in Sheffield and Leeds, and written a blog on the topic of PHPUnit. So being able to run tests directly from within my editor is super useful. Better PHPUnit not only makes it easy to quickly run tests, but makes running specific tests as simple as placing the cursor within the test method.

If you unit test, then this is one for you.

PHP Debug

If you’re still debugging your code by adding die statements here and there along with some var_dump or print_r calls, stop! Install XDebug and then grab this excellent extension for VS Code. PHP Debug will enable you to add breakpoints to your code so that you can pause the running of your app and investigate the variables currently set before proceeding to the next breakpoint. This all integrates nicely with VS Code’s built in debug mode.

Breakpoints offer greater control of how you debug, without littering your codebase with debugging methods. Once you start debugging like this you will wonder how you put up with all those die statements for so long.

Vscode Php


Visual Studio Code already comes with some great Git integration right out of the box, but GitLens takes it to the next level. This extension adds a lot of functionality to your editor with the aim of helping you gain a better insight into the history of your repositories. It adds a Git explorer for navigating your branches, some powerful comparison commands, inline git blame annotations and an easy to navigate file history panel among many other features.

Vscode Php Xdebug

GitLens is very customisable. It’s well worth loading up the extension’s settings after installing it as you may not want everything enabled to begin with. Personally I find the Code Lens a little distracting so disabled this early on.


After PHP Intelephense this is probably my next must have extension.

How To Run PHP Code From Visual Studio Code (VSCode)? - Stack ...

Markdown All in One

As alluded to previously, documentation is an important part of dev work. It’s always a good idea to have a readme file in the root of each of your projects. Markdown has become a familiar standard for these files.

Php - Vs Code Beautify Extension Not Working Correctly ...

So my last essential VS Code extension for PHP developers is Markdown All in One. It provides some helpful keyboard shortcuts, a live preview and many more features to aid you when writing in Markdown. It even supports GitHub flavoured Markdown which is great for those open-source projects you are working on.