Monday, October 5, 2015

Pear installation + CodeSniffer + Drupal CS for WAMP 2.2

Pear installation:

1-Download PEAR installer from http://pear.php.net/manual/en/installation.getting.php
2-Copy/Paste this file in your PHP installation folder (mine is C:\wamp\bin\php\php5.3.13\)
3-Run cmd with admin permissions
4-Using cmd, go to your php installation folder (mine is C:\wamp\bin\php\php5.3.13\)
5-Now run "php go-pear.phar"
6-Go through the installation process and choose options according to your preferences

CodeSniffer installation:

1-From your PHP installation folder, run:
pear install PHP_CodeSniffer
2-If installation succeeded you will get the "install ok" message
3-To check successfull installation, run this command:
phpcs -i
This will show you a list of coding standard definitions

Source: http://subharanjan.com/setup-php-codesniffer-windows-machine/

Codesniffer with Drupal code standards:

1-Download Drupal code standards "Coder" module: https://www.drupal.org/project/coder
2-Go to your Code Sniffer "standards" folder:
(mine is C:\wamp\bin\php\php5.3.13\pear\PHP\CodeSniffer\Standards)
3-Now open the zipped "coder" file and go to coder/coder_sniffer
4-Extract the "Drupal" folder inside the "standards" folder
5-In cmd do: "phpcs -i", you should see Drupal included in the list of code standards

As the CodeSniffer is installed now, you can start using this to check files by using below command:

phpcs --standard=Drupal DIRECTORY/file.php


Example usage:
phpcs --standard=Drupal C:\wamp\www\duniway4\duniway\sites\all\themes\duniway\templates\views-view-field--parts-list.tpl.php

No comments:

Post a Comment