Getting VSCode ready for PHP development

A walkthrough of a few extensions for VSCode that we find useful when developing in PHP

VSCode is a great editor that works with PHP files out of the box, however, in order for it to compete with the more established PHP editors like PHPStorm you will need to install a few extensions. I also included an extension for Silverstripe as well as a bonus one independent of the programming language. 

PHP Intelephense

IntelliSense is the name of  the code completion features in Visual Studio. This extension adds a bunch of handy features like improved code completion, signature help and symbol search which allows you to search classes and methods project-wide by simply pressing "ctrl+p" or "cmd+p" and then typing "#" followed by the search term. It is recommended to disable the default VSCode PHP IntelliSense by using the setting to avoid duplicate suggestions (set php.suggest.basic to false). You also need to have PHP installed locally and added to PATH.

Link to marketplace

From my testing I found that this is the fastest IntelliSense extension for PHP which is why I use it, but there are other ones that has about the same features that you can try out as well:

PHP IntelliSense

Crane

PHP Namespace Resolver

Import and expand classes. It also has a setting for highlighting unused classes.

Link to marketplace

PHP Debug

This is a great extension to enable debugging of PHP in VSCode. We have an article that covers setting it up with MAMP and Xdebug.

Link to marketplace

Silverstripe

Since we do a lot of development in Silverstripe I thought I would include this extension as well which adds syntax highlighting for .ss files and a few useful snippets for Silverstripe templating features. 

Link to marketplace

Git Blame

This has nothing to do with PHP, however, I find it very useful so it also made the list. It adds Git Blame information to the status bar for the current selected line of code. 

Git Blame 2

Link to marketplace


Let's work together

Contact us