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:
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.
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
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
I hope it helps in submitting your Magento extension to the community marketplace.