Enable PHP validation in Microsoft Visual Code

PHP is one of the most used server scripting language and is common in majority of the content management system. There are various code editors that you can use to write and edit PHP codes. Microsoft Visual code and Atom are most preferred among them. Atom is an open source software and is available for free which comes with many useful add-ons. Auto completion is the one feature that most of the code writers use and both of them is capable of doing it.

When you first install Microsoft Visual Code, PHP validation in not enabled but you can enable it by downloading Extensions such as PHP Intellisense.

Alternate way to enable PHP validation in Visual Code settings.

  1. Download PHP files from php.net.
  2. Extract the zip file (If you have downloaded installer file, then you have to install it).
  3. Now open Microsoft Visual Code.
  4. Then go to File > Preferences > Settings (Ctrl + Comma).Microsoft Visual Code
  5. Now copy and paste the below code in your existing settings code. Remember to change the location of PHP file that you have extracted earlier.
    "php.validate.enable": true,
    "php.validate.executablePath": "d:/php/php.exe",
    "php.validate.run": "onSave",
    PHP code validation
  6. After entering the above code save settings.json file.

Comparing both the code editors, Microsoft Visual Code seems faster however, Atom takes the lead when we compare flexibility. You can use add-ons and extensions to increase their functionalities. Both of them can be customized with a wide range of themes. You can configure the code editor window as per your need. Sublime Text is an alternative text editor for code but you have to buy the pro version to get most out of it. Notepad++ is another source code editor that supports multiple languages and is fast to load in Microsoft Windows environment. Notepad++ is free and supported by majority of the Windows versions.