Setup your VSCode as PHP code editor/IDE
Tags: php, vscode, beginners
Published: 2020-02-21 21:19:31

As you know **VSCode** became a so popular text editor which can be tuned up to any language development (JavaScript, C, C#, Java, Go, Python and many more). In this post we are going to setup one of the popular backend language, I'm talking about PHP.

### Requirements
- [VSCode](https://code.visualstudio.com/)
- PHP
- [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer) installed
- [Composer](https://getcomposer.org/)

If you are a Windows user, you can skip installing PHP and Composer in a single step using [Laragon](https://laragon.org/), in case you are Linux/MacOS you can follow this guide: https://dev.to/manuelojeda/setup-a-php-dev-enviroment-with-laravel-valet-and-wsl-1pp6

After you have installed all the things mentioned, I suggest you to install this extension in your VSCode:

#### Settings Sync
This one will let you bring your VSCode configuration anywhere you need it, only vinculate your GitHut account and you are ready to go:
https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync

After having all of this installed let is begin with the dance.

### Settings at VSCode

First of all, let's tell VSCode where is the PHP Path is. Go to **Settings** and type **php** at the search bar, then look for the section; **PHP › Validate: Executable Path** then click in **Edit in settings.json**:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xs7icezwlm7xme6kfet8.png)

Once you have opened, look of the line that it says: "php.validate.executablePath". If you have it, make sure your php installation path is there, in case you haven't add this rule to your settings.json:

In Linux and Mac should be:

`"php.validate.executablePath": "/usr/bin/php"`

In Windows should be:

`"php.validate.executablePath": "c:/Program Files/php/php.exe"`

After doing this preparation you are ready to install and make your VSCode be ready to do some PHP code, let's roll!

### Extensions

#### [PHP IntelliSense](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense)

What this extension does is giving some help depending on what version of PHP you have installed (at least PHP 7) giving you the autocompletition that Intellisense do in Visual Studio.

#### [PHP Namespace Resolver](https://marketplace.visualstudio.com/items?itemName=MehediDracula.php-namespace-resolver)

This is extension give you the posibility to auto add a Class from another file with few steps and without the necessity of tiping it at the beginning of your PHP file:

![Example on how PHP Namespace Resolver works](https://i.imgur.com/upEGtPa.gif)
Credtis to the author: **Mehedi Hassan**

#### [phpcs](https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs#review-details)

This extension linter you code and tells you what you need to have an overall standar for a PHP code made. Follow up the installation guide and enjoy having a PHP linter in VSCode.

#### [Laravel Blade Snippets](https://marketplace.visualstudio.com/items?itemName=onecentlin.laravel-blade)

This extension gives you some helpful snippets when you are coding some blade files for the views of Laravel.

#### [Composer](https://marketplace.visualstudio.com/items?itemName=ikappas.composer)

This provides an interface to manage your Composer dependencies and validates your **composer.json** config file

### Conclusion

With these extensions your PHP development will be boosted greatly and make Visual Studio Code a great free alternative in the market. I hope this post was helpul to you and I wish to you good luck in the path.