Jump to content

How to install PHP CodeSniffer and Prestashop coding standards under Windows and XAMPP


musicmaster

Recommended Posts

Having spent a lot of time finding out how to check Prestashop coding standards I want give a short intro here for those using Windows and XAMPP. My XAMPP directory is c:\xampp.

 

First of all, both PEAR and PHP CodeSniffer are already installed in the standard xampp installation. You can easily check that by going to the C:\xampp\php\ directory inside the Cmd box and typing "phpcs -i". The i-command shows a list of installed definitions. 

 

So now the only thing we have to do is downloading and installing the Prestashop coding standards. As described on the Coding Standards page, you can download the standards from a Github page. On that page, press the download button in the right column and a file "PrestaShop-norm-validator-master.zip" is downloaded.

 

You should unpack this file and copy its content under the standards directory of PHP CodeSniffer. This is C:\xampp\php\pear\PHP\CodeSniffer\Standards. As the "PrestaShop-norm-validator-master" was a bit long a shortened it to just Prestashop.

 

Checking a file or directory is now a question of typing in the Cmd box:

phpcs --standard=Prestashop /xampp/htdocs/myshop/myadmin

There is a manual with the syntax of PHP CodeSniffer.

 

One command you may want to use is 

phpcs --config-set default_standard Prestashop

It sets Prestashop as the default standard so that next time you can just type

"phpcs /xampp/htdocs/myshop/myadmin".

Edited by musicmaster (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...