0

I am trying to set the magento coding standard in the Magento 2 version. I followed this link: https://github.com/magento-ecg/coding-standard.

When I check code sniffer for the directory path: /public_html/magento-coding-standard/vendor/bin/phpcbf path to your extensions --standard=MEQP2 --extensions=php,phtml,xml,css,js

It is shows me an issue of MEQP2 not insalled .

enter image description here

Can you please guide me how can installed the Magento coding standard for the MEQP2 ?

1

1 Answer 1

0

Magento uses the EQP Coding Standard tool for checking the coding standard of a module.https://github.com/magento/marketplace-eqp

Magento a tool used basically using the PHP_CodeSniffer tool.

If you want to run EQP Coding Standard on your local system, then follow the steps:

Go to your Magento root directory, and install this too using composer: composer create-project --repository=https://repo.magento.com magento/marketplace-eqp Magento-coding-standard

Then go to this tool directly using cd magento-coding-standard

run Composer update command composer install which will update module dependency packages. Also, set config path specific PHP version set paths to php binary dir

vendor/bin/phpcs --config-set php7.0_path /path/to/your/php7

After that, you can use the below command for the checkout code start of your module from the Magento-coding-standard folder

php vendor/bin/phpcs /path/to/your/extension --standard=MEQP2

use MEQP2 for magento2 extension.

Example:

php vendor/bin/phpcs /var/www/html/MagentoProkect/app/code/DevAmitbera/CustomModule --standard=MEQP2 --extensions=php,phtml

Here I give the full path of my extension /var/www/html/MagentoProkect/app/code/DevAmitbera/CustomModule

4.1. If you use windows and face some path that must be translated related warning in the command line then try the below solution. Install Cygwin console from https://cygwin.com and then go to the Magento-coding-standard directory and run the below command.

vendor/bin/phpcs F:/xampp/htdocs/magento2/app/code/DevAmitbera/CustomModule --standard=MEQP2 --severity=10 --extensions=php,phtml

After That, I have run the code sniffer auto fixer command which is a basic code standards issue.

php vendor/bin/phpcbf /path/to/your/extension -extensions=php,phtml --standard=MEQP2

Example:

  php vendor/bin/phpcbf /var/www/html/app/code/DevAmitbera/CustomModule --standard=MEQP2 --extensions=php,phtml

After re-run Step 4 command for checking out the rest of errors which you need to fix yourself manually.

2
  • I follow the same steps it is still not showing Magento 2 or MEQP2 option that will validate Magento 2 plugins. Feb 10 at 14:00
  • Try this command make sure you update your vendor and module name--> vendor/bin/phpcs --report=xml --report-file=MEQP.xml app/code/Vendor/ModuleName --standard=Magento2 --severity=10 -p Feb 11 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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