Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Last active September 17, 2022 17:05
Show Gist options
  • Save ipokkel/7e450d7e2665bd8d6475578f3f167b5e to your computer and use it in GitHub Desktop.
Save ipokkel/7e450d7e2665bd8d6475578f3f167b5e to your computer and use it in GitHub Desktop.
PHPCS + WordPress Coding Standards on Windows 10

Wordpress Coding Standards on Windows 10

Use Git Bash instead of default command line https://git-scm.com/download/win

Visual C++

Download and install Visual C++: https://aka.ms/vs/15/release/VC_redist.x64.exe

PHP

Download PHP: https://windows.php.net/download/ || https://windows.php.net/downloads/releases/php-7.3.7-nts-Win32-VC15-x64.zip

  • Create a new folder in c:\php7 and extract your PHP zip to it.
  • Add c:\php7 as Path Environment Variable
  • Open System Properties by clicking the start menu and typing sysdm.cpl and press Enter.
  • In System Properties, click Environment Variables.
  • In System Variables, click Path and then click Edit.
  • Click New, type the path to your PHP folder (c:\php7) and click OK.
  • Close the System Properties dialogue by clicking OK.
  • If you have any Command Prompt windows currently open, close them.
  • Open Command Prompt, type php -v and press Enter. You should now see the PHP version.

Composer

Install Composer: https://getcomposer.org/download/

  • If Setup prompts to create php.ini, allow it and click Next.
  • Skip the Proxy URL settings, just click Next then click Install.
  • Click Finish once install is complete.

PHPCS

In Git Bash command prompt

composer global require "squizlabs/php_codesniffer=*"

WordPress Coding Standards

In Git Bash command prompt

  • composer global require "wp-coding-standards/wpcs"
  • phpcs --config-set installed_paths C:\\Users\\USERNAME\\AppData\\Roaming\\Composer\\vendor\\wp-coding-standards\\wpcs (Replace USERNAMEwith your actual username)
  • phpcs --config-set default_standard WordPress-Extra
  • phpcs -i should now return "The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz, Zend, WordPress, WordPress-Core, WordPress-Docs and WordPress-Extra"

Credits

https://gist.github.com/nunomorgadinho/b2d8e5b8f5fec5b0ed946b24fa288a91

https://devanswers.co/install-composer-php-windows-10/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment