InterServer Web Hosting and VPS

Best Php Extension for Visual Studio Code 2022

PHP is undeniably one of the most used programming languages in the world. There are many websites, social media platforms, corporate giants and so much more built with PHP. However, PHP has not taken over the number 1 spot yet although it’s still the most dominating programming language out there.

Get VS Code by Microsoft, it is absolutely competent with the PHP language. It’s something that shocked me personally when it was released as I didn’t expect it for being prepared for PHP developers. But yep, it is a strong development environment for PHP, and of course, there are plenty of extensions to be used with it.

The development company is working hard to best suit PHP in Visual Studio Code. You can use this extension to create or edit your projects which are written in PHP. The main features are syntax coloring, snippets, conversions, and debugging assistance.

Php Intelephense is the best Php extension for visual studio code, with great support for different development tools.

Visual Studio Code Extension

VSCode is an incredibly powerful editor. By default, it is most known for its use with JavaScript (due to the .js file extension that most modern web frameworks use). With the extension ecosystem of VSCode however, the breadth of languages and functions of this software can be extended.

Extended PHP Intelephense is an extension that adds a whole bunch of functionality to your editing environment. The interesting thing about this extension is that it is developed by a community of volunteers and has been seeing a lot of updates in the last few years. There are dozens of extensions for PHP that can be utilized with Visual Studio Code, and below I have made a list of the very best ones to use.

Import Checker

When using PHP frameworks like Laravel, declaring classes to use at the top of the file becomes widely used. But, over time, you’re bound to have a cluttered list of classes, and one of them won’t be of required use. This checker extension essentially ‘lints’ those classes that aren’t necessary to your file and highlights them for deletion. Essentially, it’s a cleaning tool for your code and a good one at that.

PHP Files Extension

VSCode doesn’t come fresh out of the box all-singing-all-dancing, and that is why this extension was created. After installing, you will have access to three pre-formatted file type creating functions, namely, classinterface and trait. After selecting either of these as your creation file type, all you have to do is name it, and the file will be created, pre-filled with code, ready to go!

When specifying interface names, the possibility of comma-separating is present, meaning that the code will be pre-filled with these defined names. It’s well worth checking out.

PHP Intellisense

First and foremost is Intellisense, I don’t think I could live without this one. Intellisense will offer to autocomplete on native PHP functions while you type. This extension by Felix Becker is super-responsive too, meaning unlike some other IDE’s, it always instantly gives you options within your autocomplete dropdown.

PHP Debug

Although VSCode comes with a Debug widget fresh out the box, it doesn’t necessarily mean it works with all programming languages instantly. PHP is no exception, and you must download the framework for debugging to work with Visual Studio Codes debug module.

I wrote an article on how to set up debugging PHP with VS Code a while back. The tutorial instructs how to configure for code-level simulation debugging and live-browser debugging. This is another feature that I couldn’t live without, and I’m almost sure that it’s the same for you!


What on earth is DocBlocker I hear you ask, well, if you are asking that question, essentially a DocBlock is a comment block. See the following code snippet for example –


This extension makes it very quick to append this block to your code, wherever you may need it. What’s also great is that it comes packed with comment tags like @author, @method, @group, and @return. You can quickly get access to these tags with their respective snippets by pressing the @ symbol and choosing from the drop-down list. Here is another example of the DocBlocker with some tags.

class myClass 
     * @method mixed myMethod()
     * @author CodeWall <[email protected]>
     * @param mixed $myParam
    public myMethod($myParam)


So, if you’re a big fan of comments, this way of commenting code is well worth putting into practice. It’s not only helpful but the style is known industry-wide.

phpfmt – PHP formatter

Because we coders love to type super-turbo-fingered-fast, we can’t always guarantee that our code layout is correctly tabbed and indented. With the above extension, you don’t have to worry, with a quick tap of CTRL + ALT + F, the extension will magically format the PHP into a pretty formatted file. You can also configure the extension to run its formatting every time you save the file too.

A quick note with this extension though, is that you must have the path to the PHP engine specified to work properly. Whether that be on a server on your local machine, it must be specified in the VSCode extension settings.

PHP Getter & Setter

Another convenient extension is the Getter & Setter package, I’ll give you half a millisecond to work out what it does. Yep, you guessed it, this extension quickly adds ‘get and set functions to your code. It’s as simple as right-clicking on the variable you want getters and setters for and executing the extensions helper. This extension will turbo-charge your object-oriented PHP development.

See the following code for an example of what it adds to your file for you.

     * Get the value of myVar
    public function getMyVar()
        return $this->myVar;

     * Set the value of myVar
     * @return  self
    public function setMyVar($myVar)
        $this->myVar = $myVar;

        return $this;

Custom Snippet Pack

Just in case you are not aware of what snippets are, they mainly are keywords that you type out and hit return to print out a particular snippet of code to your file. For example, in this snippet pack, if we type ‘c’ and hit return, a full PHP class will be written to your file in an instant. These of course are extremely handy and help speed up development. The above pack has all super-globals and a few class-based snippets too.

PHP Storm Snippet Pack

If you’ve used PHP Storm before, you’ll already know about these handy snippets, if not, no worries, you know about them now! This pack has shortcuts for loops like,foreach require and include commands and more class-based snippets. Visit the link above for a data table showing each shortcut and its description.


The Prettier VS Code extension is for code formatting.

1. CMD + Shift + P -> Format Document
1. Select the text you want to Prettify
2. CMD + Shift + P -> Format Selection


After installing this extension you can easily run queries and test your queries directly from VS Code. Right-click the database and click “New Query” then type your query, right-click and run the query, which will show the results on the side.

Query and its results in vscode


Git in VS code. Install it, connect to GitHub or bitbucket or Git and you can directly push code from the VS code.

Editor Config

EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. Install the extensions and right-click in the project and click “Generate .editorconfig” which will create the .editorconfig file by which all indent style, indent size trim trailing whitespace will be the same for all developers. This will remove the formatting issues for different developers.

root = true

indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

You can share your Visual studio code with others and get real-time collaborative development within VS Code.

PHPCS (PHP CodeSniffer) – Ioannis Kappas

This extension offers an interface for PHP CodeSniffer. PHP CodeSniffer scans the PHP files in your workspace to detect and offer suggestions and fixes for violations of a defined set of PHP standards. It’s an excellent extension that will ensure you strictly follow the standards for PHP.

You can learn more about PHP standards here. For you to use this extension, you need to install PHP CodeSniffer globally into your development machine. You can install PHP CodeSniffer using either PEAR or Composer as shown below.

pear install PHP_CodeSniffer

// Composer:
composer require --dev squizlabs/php_codesniffer


To install PHPCS, press F1 on Visual Studio and type the following command:

ext install phpcs


You can learn more about this extension here.

PHP Intellisense Crane – Hvy Industries

 To use the creator’s words, PHP Intellisense Crane is a productivity enhancement extension for Visual Studio Code that provides code completion for PHP. It has zero dependencies and largely works with projects of any size. The extension is active in development and you can raise issues and make feature suggestions on GitHub. This extension offers the following features: Code Completion, Go To and Peek Definition on classes, interfaces, and traits and document workspace symbol provide. To install PHP Intellisense Crane, press F1 on Visual Studio Code, and type the command below.

ext install crane


Once installation is complete, wait for it to parse all PHP files in your workspace. You will see a progress bar at the status bar.

You can learn more about PHP Intellisense Crane here.

PHP Intelephense – Ben Mewburn

This is one of the best PHP Extension I have ever used. It provides a tonne of useful features without affecting negatively the performance of Visual Studio Code. It also has no external dependencies. It has the following features:

  • Fast camel/underscore case code completion (IntelliSense), offering detailed suggestions for document, workspace and built-in symbols and keywords.
  • Detailed signature (parameter) help for document, workspace and built-in constructors, methods, and functions.
  • Rapid workspace wide go to definition support.
  • Workspace wide find all references.
  • Fast camel/underscore case workspace symbol search.
  • Full document symbol search.
  • Multiple parse error diagnostics for open files via an error tolerant parser.
  • Lossless PSR-2 compatible document and range formatting.
  • Convenient command to add use declarations and condense referenced names.
  • HTML request forwarding allowing for a full HTML/Javascript/CSS/PHP development experience.

To install this extension, press F1 and type in the command below:

ext install bmewburn.vscode-intelephense-client


You can learn more about this extension here.

PHP Intellisense – Felix Becker

Just like the name suggests, it offers Intellisense autocompletion for PHP. This extension depends on PHP Language Server to work. The extension just provides an interface to the PHP Language Server. To use this extension, first install the PHP Language Server using composer as shown below:

composer require felixfbecker/language-server


If you have multiple projects, you can install PHP Language Server globally as follows:

composer global require felixfbecker/language-server


You also need to have PHP7 installed in your system. Then go ahead and install the extension on Visual Studio Code. Press F1 and type in the following command:

ext install php-intellisense


You can learn more about the extension here.

PHP Debug – Felix Becker

Visual Studio Code- Top 5 Extension for PHP. This extension is an adapter for XDebug extension for PHP. XDebug is an extension for PHP that assists with debugging and development of PHP projects. To use this application, you need to install XDebug and PHP into your system.

You can follow the instruction found on the extension page here. To install this extension, press F1 and type in the command below.

ext install php-debug.


In this post, we looked at some of the popular PHP extensions available for Visual Studio Code and Intellisense. We also look at some custom extensions developed by the community and shared on VS Code Marketplace. There are a lot of articles on the internet about the best PHP extensions for Visual Studio Code and many other articles on how to use them. But what you mostly see are step-by-step instructions on how to install and configure them and nothing more.

This article will help you to find your required Best PHP Extension for Visual Studio Code. Choosing the right plugin makes your job easier and increases productivity.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *