1

Unable to install magento-ecg/coding-standard to PHP_CodeSniffer: Tried below command after cloning PHP_CodeSniffer from github:

phpcs --config-set installed_paths ./vendor/magento-ecg/coding-standard

But phpcs -i is showing only following standards.

The installed coding standards are PSR1, MySource, Zend, Squiz, PHPCS, PEAR and PSR2

  • If you have a possibility try to put it in default path and see if it works: /usr/share/php/PHP/CodeSniffer/Standards/ Another thing you can try is using full path to standards directory: phpcs --config-set installed_paths /home/your_user/vendor/magento-ecg/coding-standard – versedi Mar 1 '16 at 15:20
8

facing the same problem solved it by

git clone https://github.com/magento-ecg/coding-standard

then added the complete path where you clone it

phpcs --config-set installed_paths /home/your_user/vendor/magento-ecg/coding-standard

End reuslt phpcs -i

The installed coding standards are PSR1, PSR2, PEAR, MySource, PHPCS, Zend, Squiz, Ecg and EcgM2

  • I have taken clone in my magento 2 folder. for below command what will be the installed_paths? Also what will be /home/your_user/vendor/magento-ecg/coding-standard? phpcs --config-set installed_paths /home/your_user/vendor/magento-ecg/coding-standard – jack May 18 '18 at 5:49
  • @jack which folder your standard is located that will be installed path – Qaisar Satti May 18 '18 at 18:12
0

i followed below steps in windows local system first installed xammp

  1. cd C:\xampp\php
  2. pear install PHP_CodeSniffer pear install --alldeps PHP_CodeSniffer

(if there is any issue run cmd as Administrator)

enter image description here

phpcs -i

  1. then to follow Magento coding install magento-ecg/coding-standard from composer

  2. after install it will be in C:\xampp\htdocs\magento217\vendor\magento-ecg\

  3. now run (C:\xampp\php>)

    phpcs --config-set installed_paths C:\xampp\htdocs\magento217\vendor\magento-ecg\coding-standard

now it will have all plugins need for M2

phpcs -i

The installed coding standards are PSR1, PSR2, PEAR, MySource, PHPCS, Zend, Squiz, Ecg and EcgM2

To test Module run below code

C:\xampp\php>phpcs C:\xampp\htdocs\magento217\app\code\NAMESPACE\MODULE_NAME

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.