Schedule a Free Consultation
Install Php Code Sniffer on Windows & PHPStorm

Install Php Code Sniffer on Windows & PHPStorm

Read Article

If you are concerned about delivering high-quality code, compliant with WordPress coding standards, you’d better use an automated tool for these checks.

PHP Code Sniffer together with PHPStorm editor is a great and powerful combination as you get all these code checks in real time, as you type your code.

There are many great tutorials on how to install PHP Code Sniffer with PHPStorm on Mac, but we did not find any article explaining how to install and configure these tools on Windows.

So here’s a small contribution for those who need to check their code on Windows:

  • Using Composer
  • Using PEAR
    • Install PHP. Suggested are bundle: XAMPP OR WAMP
      1. Restart computer
      2. XAMPP ship with PEAR and PHP_CodeSniffer you can skip steps 2-
      3. To check if PHP_CodeSniffer is installer run this command in CMD: phpcs -i
    • Add System Environment variable: https://www.screencast.com/t/1zs1WY31l with link to PHP.exe from BIN folder
    • How to install PEAR(if needed)
      1. Download from: http://pear.php.net/go-pear.phar
      2. Copy PEAR to php location
      3. Open CMD to this location. Can be done two ways
        1. RUN -> write cmd -> CD into your php server folder
        2. Open Explorer -> go to PHP location -> SHIFT + RIGHT CLICK there and open SHELL
      4. RUN command php go-pear.phar
        1. Check folder settings to be OK
        2. Follow on screen details and complete installation
    • Install PHP_CodeSniffer
      1. Run command from cmd(see step 3-C-i and 3-C-ii) pear install PHP_CodeSniffer from PHP -> PEAR folder
      2. Download WORDPRESS STANDARDS from https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/master.zip
      3. Unpack the archive folders: https://www.screencast.com/t/jgucqIDo to ~phpPEARphpCodeSniffersrcStandards where ~ means path to PHP
    • For Updates you need to download the WORDPRESS STANDARDS from the link above and copy them to CodeSniffer location.
  • PHPStorm settings – is suggested to work on “default settings” dialog (from File)

Reference:
https://github.com/squizlabs/PHP_CodeSniffer
https://w3guy.com/setup-php-code-sniffer-phpstorm-windows/
https://kellenmace.com/set-up-php-codesniffer-in-phpstorm-with-wordpress-coding-standards/

Navigate to

You Might Also Enjoy These Digital Marketing Articles:

How to Compile IMAP With SSL for PHP on OSX - Works on MAMP As Well - WPRiders Article
How to Compile IMAP With SSL for PHP on OSX – Works on MAMP As Well
This tutorial is an attempt to alleviate the headaches for all those that need to have IMAP with SSL running on OSX😃 Needed Stuff autoconf openssl libxml2 imap2007 install with brew “brew install imap-uw” OR download fromhttps://www.mirrorservice.org/sites/ftp.cac.washington.edu/imap/(the archive without Z at the end ) imap-2007e ftp://ftp.cac.washington.edu/imap/ To install libxml2, you can use brew: brew install […]
How to Find the Right Fit for Your Business Size - WP Engine Alternatives for Small Businesses and Startups with Help from WPRiders - WPRiders Article
How to Find the Right Fit for Your Business Size – WP Engine Alternatives for Small Businesses and Startups with Help from WPRiders
Explore WP Engine alternatives like Kinsta, Cloudways by DigitalOcean, and Pressable. Learn how to choose the right WordPress hosting based on your company size and goals with expert tips from WPRiders—perfect for small businesses and startups!
Top 10 Reasons to Use a WordPress Maintenance Service - WPRiders Article
Top 10 Reasons to Use a WordPress Maintenance Service
In the following article, you will learn the top 10 reasons you should use a WordPress Maintenance Service for your website if you are serious about your online business. WordPress started as a blogging platform and did a phenomenal transition to an excellent CMS, which now, according to W3Techs, powers 43% of all online websites […]