How To Set Up Visual Studio Code (VS Code) for PHP Development | DigitalOcean

VS Code Options

Our general settings for VS Code – see here

Web development specific settings

Use CTRL+SHIFT+P and then enter “Open User Settings (JSON)” to open the raw json file. Check it has the following:

	"[php]": {
		"editor.insertSpaces": true,
		"editor.tabSize": 2
	},

Extensions

PHP Intelephense by Ben Mewburn

Adds PHP auto completions etc.

WordPress Hooks IntelliSense

WordPress specific autocomplete etc

PHP Debug

Makes it easy to use the xDebug tool for breakpointing and stepping through PHP code.

SFTP by Natizyskunk

FTP/SFTP access. (PRO Developer also looks good for this?)

WordPress specific settings

Adding WordPress functions so PHP linting doesn’t mark them as errors

Press (Ctrl+Shift+X) for the extensions and search for PHP Intelephense.

Click the settings icon of the extension and choose Extension Settings.

Scroll down to the bottom to see the list of Stubs.

Click on Add Item and choose wordpress from the list.

This will solve the issue with built-in WordPress Functions, but it will not recognize any functions from installed plugins and themes of course.

Workspaces

VS Code Workspaces are really good for web dev work, as a way to create a kind of container for the project you are working on that can have its own settings and be opened again the same in the future.

See here

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

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