Configure Code Sniffer With Netbeans (MEQP2 OR Magento 2 standard)

CodeSniffer, an essential code review tool which helps you to make your code clean and consistent, specially when we work with Magento we should make it our habit to use such tools to have better development process. This blogpost is for those who uses NetBeans IDE for Magento 2 development, here are the steps to integrate PHP CodeSniffer with NetBeans IDE using MEQP2 standards.

Note:- Make sure that you have code sniffer already steup as this blogpost only explains code sniffer configuration with netbeans.

Code Sniffer configuration steps in netbeans:

• Open NetBeans IDE (this process is for Netbeans 8.2).
• Go to tools-> Plugin and install the NetBeans plugin ‘phpCS-MD’. You will get it under “Available Plugins” tab. If it does not show then check next step, it will be already setup then.

• Now go to “Tools” -> “Options”->”PHP”->”Code Analysis”.

• Click on the tab “CodeSniffer”.
Here you have to provide the path to phpcs.bat file present under your PHP installation directory. Do this by clicking the “Browse” button there.

• Now you need to select the coding standard for which you want to test your application, in our case it is MEQP2. Select it and click ok to complete configuration.

Testing Code using code sniffer in netbeans:

To test the code just select file or folder from project directory and the go to source > inspect to get the below screen:-

Click on Inspect button to get the list of all issues and warning:-

Hope this helps, just drop in your comment for any issue.

Leave a Comment.