<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Snwobytes</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Snwobytes"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/Special:Contributions/Snwobytes"/>
	<updated>2026-06-09T12:04:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Setting_up_VSCode&amp;diff=58007</id>
		<title>Setting up VSCode</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Setting_up_VSCode&amp;diff=58007"/>
		<updated>2020-11-06T21:35:06Z</updated>

		<summary type="html">&lt;p&gt;Snwobytes: remove phpfmt (incompatible with standards), remove phpcs (php sniffer does its job + formatting), add debugging+intellisense, reorganize sections, update titles.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://en.wikipedia.org/wiki/Visual_Studio_Code VSCode] is a an Integrated Development Environment from Microsoft available under the MIT License.&lt;br /&gt;
It works on Linux/Windows/OSX. It has a large number of plugins available, most entirely free/libre. It has good support&lt;br /&gt;
for Xdebug.&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
[https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug PHP Debug] adds debugging capability for PHP files, which is essential. Follow the extension&#039;s installation instructions.&lt;br /&gt;
&lt;br /&gt;
== Intellisense ==&lt;br /&gt;
[https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client PHP Intelephense] is the standard php plugin for [https://code.visualstudio.com/docs/editor/intellisense intellisense] features.&lt;br /&gt;
&lt;br /&gt;
== Linting ==&lt;br /&gt;
[https://en.wikipedia.org/wiki/Lint_(software) Linting] plugins will show wavy red lines under code that does not conform: [[File:phpcs_sniff.png]]&lt;br /&gt;
The linters used for development are:&lt;br /&gt;
* [https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint stylelint] for CSS&lt;br /&gt;
* [https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint ESLint] for JS&lt;br /&gt;
* [https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer PHP Sniffer] for PHP. It requires [https://github.com/squizlabs/PHP_CodeSniffer phpcs v2.* (package)] installed and configured to use moodle&#039;s standards.&lt;br /&gt;
To do so, run the following in your terminal from your moodle folder:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
composer global require &amp;quot;squizlabs/php_codesniffer=2.*&amp;quot;&lt;br /&gt;
composer require --dev &amp;quot;blackboard-open-source/moodle-coding-standard&amp;quot; # installs moodle&#039;s coding standard&lt;br /&gt;
phpcs  --config-set  installed_paths vendor/blackboard-open-source/moodle-coding-standard # adds moodle&#039;s standard to phpcs&lt;br /&gt;
phpcs -i # checks which standards are available to phpcs&lt;br /&gt;
phpcs --config-set default_standard moodle # sets moodle as the default standard for phpcs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
If it is installed moodle will show up in the output of `phpcs -i`, here is a typcial example, note moodle is listed as the last but one item.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
The installed coding standards are PEAR, PHPCS, Zend, PSR2, MySource, Squiz, PSR1, moodle and PHPCompatibility&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code Formatting ==&lt;br /&gt;
If you have [https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer PHP Sniffer] installed, configure it to be the default formatter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
// add this [php] key/value pair in vscode&#039;s user settings (settings.json):&lt;br /&gt;
{&lt;br /&gt;
  // ...&lt;br /&gt;
  &amp;quot;[php]&amp;quot;: {&lt;br /&gt;
    &amp;quot;editor.defaultFormatter&amp;quot;: &amp;quot;wongjn.php-sniffer&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Automated testing ==&lt;br /&gt;
[https://marketplace.visualstudio.com/items?itemName=danilopolani.yet-another-phpunit Yet Another PHPUnit] lets you run automated tests from within vscode.&lt;br /&gt;
&lt;br /&gt;
== Docblocks ==&lt;br /&gt;
[https://marketplace.visualstudio.com/items?itemName=neilbrayfield.php-docblocker PHP DocBlocker] to create a docblock by typing /** at the top of a function and it grabs the parameters, including types if given and creates a PHPDoc block.&lt;br /&gt;
&lt;br /&gt;
== Moodle specific Snippets and autocomplete ==&lt;br /&gt;
[https://marketplace.visualstudio.com/items?itemName=MateuszLesiak.vscode-moodle-snippets Moodle - Snippets &amp;amp; Autocomplete] offers some useful Moodle specific code completion popups.&lt;br /&gt;
&lt;br /&gt;
== Auto trim trailing white space == &lt;br /&gt;
To ensure trailing white space is trimmed do the following &lt;br /&gt;
&lt;br /&gt;
Open VS User Settings (Preferences &amp;gt; Settings &amp;gt; User Settings tab).&lt;br /&gt;
Click the {} icon in the top-right part of the window. This will open a document.&lt;br /&gt;
&lt;br /&gt;
Add a new &amp;lt;code&amp;gt;&amp;quot;files.trimTrailingWhitespace&amp;quot;: true&amp;lt;/code&amp;gt; setting to the User Settings document if it&#039;s not already there. &lt;br /&gt;
This is so you aren&#039;t editing the Default Setting directly, but instead adding to it.&lt;br /&gt;
&lt;br /&gt;
Save the User Settings file.&lt;/div&gt;</summary>
		<author><name>Snwobytes</name></author>
	</entry>
</feed>