Skip to content

Instantly share code, notes, and snippets.

@udovicic
Last active January 6, 2021 19:16
Show Gist options
  • Save udovicic/acc0452666cc63204d91e2f21b1bc12f to your computer and use it in GitHub Desktop.
Save udovicic/acc0452666cc63204d91e2f21b1bc12f to your computer and use it in GitHub Desktop.
Instructions for setting up Magento 2 code analysis with PHPSTorm

Setting up MEQP Coding standard checks in PHPStorm

Overview

In order to submit extensions to Magento marketplace, source code needs to pass Magento Extension Quality Program Coding Standard checks.

You can either do it manually, by following this guide in official Github repository, or by fixing things as you code, by setting up check in PHP Storm.

Install and configure Code Sniffer on system

  • Install the phpcs to your system by executing:
# pear install PHP_CodeSniffer
$ git clone [email protected]:magento/marketplace-eqp.git 
  • Locate where phpcs sotres standards and copy them from the repo above. On Ubuntu based systems, they are located in /usr/share/php/PHP/CodeSniffer/Standards. You have to copy MEQP1, MEQP2 and Utils folders there:
# cp -R marketplace-eqp/MEQP1 /usr/share/php/PHP/CodeSniffer/Standards/
# cp -R marketplace-eqp/MEQP2 /usr/share/php/PHP/CodeSniffer/Standards/
# cp -R marketplace-eqp/Utils /usr/share/php/PHP/CodeSniffer/Standards/

PHPStorm setup

  • Make sure you have configured PHP interprter. You can do so by going to

Languages & Frameworks > PHP

  • Make sure you have confiugred PHP Code Sniffer. You can do so by going to

Languages & Frameworks > PHP > Code Sniffer

  • Enable code sniffer and choose validation standard:

Editor > Inspections > PHP

  • Find PHP Code Sniffer Validations and tick the box next to it, in order to turn it on

  • On the right pane, select MEQP1 for Magento 1 validation, or MEQP2 for Magento 2 validation

@lfluvisotto
Copy link

@michielgerritsen, good catch.

I added via composer require magento/marketplace-eqp --dev in the project

In Languages & Frameworks | PHP | Quality Tools | Code Sniffer, I set the path vendor/bin/phpcs and worked without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment