0

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 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 at 13:55
  • can you provide the coding standard github link to know which coding standard you're using? – Mohit Rane Jul 9 at 13:57
  • try phpcbf command after running this command cd magento-coding-standard – Mohit Rane Jul 10 at 7:21
  • you can check it by this command which phpcbf to see if it's installed or not – Mohit Rane Jul 10 at 7:44
2

Inside project

Install

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

Usage

// 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"

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.