4

I want to check My Extension's coding standard for Magento Marketplace before submitting it on **Magento Marketplace*. Can anyone tell me how can I install coding standard in My Local Environment and check my extension whether this extension is eligible or not for Magento Marketplace code standard.

Thanks In Advance..!

2 Answers 2

5

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

Magento this tool used basically using PHP_CodeSniffer tool.

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

  1. Go to your Magento root directory, install this too using composer:

composer create-project --repository=https://repo.magento.com magento/marketplace-eqp magento-coding-standard

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

  2. 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

  1. After that, you can use below command for checkout code start of your module from 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 full path of my extension /var/www/html/MagentoProkect/app/code/DevAmitbera/CustomModule

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

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

  1. After That, I have tun code sniffer auto fixer command which is 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 check out the rest of error which you need to fix yourself manually.

13
  • 1
    I will try and let you know, If My extension is pass in this than it will approved in Magento Marketplace ? Commented Apr 16, 2019 at 9:00
  • 1
    You have to follow also https://docs.magento.com/marketplace/user_guide/Resources/pdf/Extension_Quality_Program_Overview.pdf and
    – Amit Bera
    Commented Apr 16, 2019 at 9:03
  • 1
    prntscr.com/nclrtq Commented Apr 16, 2019 at 9:20
  • 1
    Can you please help me to solve code_sniffer related issue. Commented Apr 16, 2019 at 10:13
  • 1
    I am run command from "magento-coding-standard" folder php vendor/bin/phpcs ../app/code/Cirkle/Behalf --standard=MEQP2 and got this error : prntscr.com/nd0yv5 Commented Apr 17, 2019 at 6:02
0

Not just for Magento, the coding standard for any extensions or solutions before submissions follow the same. But in Magento, it is a stably even more conscious process.

Also, all must look for the best practices to pass the extension quality program curated by the Magento marketplace.

For adequate and proper flow, the Magento community follows several guidelines and verification tools to check if it stays the level to pass the Magento coding standards. It might go through - logical and practical coding structure, scalability, performance and absolute compatibility with the latest Magento version.

Technically, the code standard process for any Magento extension would have to count the following levels:

Level 1:

The first level is a must one, and it checks all the extensions before letting them into the marketplace to examine the code structure and plagiarism issues.

Level 2:

Extensions that pass Level 1 can enter level 2 with an official badge called “ Top Quality Badge” received from the platform. After all, the extension is free to go via a series of checks like - Documentation, Deep Code, Sanity Check/QA Review.

Step 1 – Go to your Magento 2 root folder using the following command:

$ composer create-project --repository=https://repo.magento.com Magento/marketplace-eqp Magento-coding-standard

Step 2 – Set dynamic sniffs by running the following command:

$ vendor/bin/phpcs --config-set m2-path /path/to/magento2

Step 3 – Go to the Magento-coding-standard folder, which should be installed on your Magento root folder using the following command:

$ cd Magento-coding-standard

Step 4 – Run your code against Magento 2 coding standards to check:

$ vendor/bin/phpcs /path/to/your/extension --standard=MEQP1 and $ vendor/bin/phpcs /path/to/your/extension --standard=MEQP2

Step 5 – Fixing Errors Automatically

PHP_CodeSniffer offers the PHP Code Beautifier and Fixer (phpcbf) tool. It can be used in phpcs to automatically generate and fix all fixable issues.

We highly recommend running the following command to fix as many sniff violations as possible:

$ vendor/bin/phpcbf /path/to/your/extension --standard=MEQP1 and $ vendor/bin/phpcbf /path/to/your/extension --standard=MEQP2

If you are building an extension for Magento Marketplace, then make sure you run the following command on your version before submitting the extension for technical review:

$ vendor/bin/phpcs /path/to/your/extension --standard=MEQP2 --severity=10 --extensions=php,phtml

I hope it helps in submitting your Magento extension to the community marketplace.

Your Answer

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

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