Visual Studio Code – Top 5 Extensions for PHP

PHP: Frameworks vs Microframeworks

Visual Studio Code is one of the best free text editors out there. Right out of the box, Visual Studio Code offers basic PHP support but nothing more than that. To enjoy a fruitful PHP development, you need to install PHP extensions. Today, I am going to highlight 5 extensions you might want to consider.

If you would like to try out Visual Studio Code, you can download it here.

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 standard for PHP. You can learn more about PHP standard 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: 
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

Visual Studio Code - Top 5 Extensions for PHP

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 suggestion on GitHub.

This extension offers the following features: Code Completion, Go To and Peek Definition on classes, interfaces and traits and document workspace symbol provides.

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 show 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 Extensions 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 in the extension page here.

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

ext install php-debug.

7 Replies to “Visual Studio Code – Top 5 Extensions for PHP”

    1. Yes, they do but they have features that are unique to each. Actually, if you add intelliphense, it also offers intellisense but has formatting and other features the other two don’t. I put the three extensions there since different people have different preferences.

  1. Do you have any idea if they interfere with each other?
    Any issues that you may have seen? I had installed the three of them .. but it becomes a lil bit slower indexing, cuz I don’t know which one is working on or which one it may be unnecessary .

    ( Sorry my English )

    1. Yes, they do interfere with each other especially the three with intellisense. After some time, I uninstalled Intellisense Crane – Hvy Industries and PHP Intellisense – Felix Becker and I remained with PHP Intelephense it works much better. Also had to disable PHP CodeSniffer because it slows the editor when indexing. So, I would suggest just using PHP Intelephense for intellisense and may be PHP Debug if you have to use debug tools for PHP.

Leave a Reply

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