I have faced issue in "vendor/bin/phpcbf" command for resolving custom extension coding standard.

I am using Magento ver.2.3.1

Running command in project root:

vendor/bin/phpcbf "app/code/Namespace/MyModule"

But while running command through below error:

PHP Fatal error: Uncaught Error: Class 'PHP_CodeSniffer\Runner' not found in /var/www/html/magento/vendor/bin/phpcbf:17 Stack trace:

0 {main} thrown in /var/www/html/magento/vendor/bin/phpcbf on line 17

Any help would be appreciated. Thanks.

  • can you share a screenshot to get more idea about the error? – Mohit Rane Jul 9 '19 at 13:54
  • 1
    use whole path like this vendor/bin/phpcbf /var/www/html/magento/app/code/Vendor/Module --standard=MEQP2 – Mohit Rane Jul 9 '19 at 13:55
  • can you provide the coding standard github link to know which coding standard you're using? – Mohit Rane Jul 9 '19 at 13:57
  • try phpcbf command after running this command cd magento-coding-standard – Mohit Rane Jul 10 '19 at 7:21
  • you can check it by this command which phpcbf to see if it's installed or not – Mohit Rane Jul 10 '19 at 7:44

Inside project


composer require squizlabs/php_codesniffer:^3.4

// magento ruleset
composer require magento/magento-coding-standard

// auto ruleset installer – automatically pickup 'phpcodesniffer-standard' packages
composer require dealerdirect/phpcodesniffer-composer-installer


// should see Magento2 standard listed
vendor/bin/phpcs -i
vendor/bin/phpcbf -i

vendor/bin/phpcs --standard=Magento2 app/code/Xigen/Vehicle
vendor/bin/phpcbf --standard=Magento2 app/code/Xigen/Vehicle

vendor/bin/phpcs --standard=Magento2 app/code/Xigen/Data --report-file="Data.txt"
vendor/bin/phpcbf --standard=Magento2 app/code/Xigen/Data --report-file="Data.txt"
|improve this answer|||||
  • Get error: ERROR: the "Magento2" coding standard is not installed. The installed coding standards are Zend, PSR2, PSR1, PEAR, Squiz, MySource and PSR12 – Dhaduk Mitesh Dec 18 '19 at 10:51
  • You're not picking up the magento ruleset which means either second two composer commands didn't work or phpcs you are triggering which can be determined by path is not inside project folder – Dominic Xigen Dec 18 '19 at 12:28

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.