PHP_CodeSniffer or phpcs is a tool that helps developers maintain a specific standard in the way they write code. In order to be able to provide relevant information, phpcs needs to be configured correctly in PHPStorm (see image).

Whether you just cloned or you are already working on a project, follow the below guide on how to prepare your environment.

When cloning a project

Step 1:

Windows Terminal: Move to the directory where you want to clone the project

Step 2:

Windows Terminal: Clone the project

Step 3:

PHPStorm: install composer dependencies

Step 4:

PHPStorm: restart

Step 5:

PHPStorm: Open Settings (FIle -> Settings) and go to PHP -> Quality Tools -> PHP_CodeSniffer:

  • Make sure that the inspection button is ON
  • Coding standard is set to Custom and the field next to it contains the path to your project’s phpcs.xml file

For an existing project

Step 1:

PHPStorm: Open Settings (FIle -> Settings) and go to PHP -> Quality Tools -> PHP_CodeSniffer. There, if Coding standard is set to Custom and the field next to it contains the path to your project’s phpcs.xml file, then PHPStorm is configured correctly to use phpcs – NO need to continue with the next steps.

Step 2:

PHPStorm: delete (if exists) the vendor directory

Step 3:

PHPStorm: install composer dependencies

Step 4:

PHPStorm: restart

Step 5:

Go to Step 1.

After you have the above configurations, you should start seeing information in the top-right corner of the editor.

Once the PHPStorm has finished analyzing the opened file, you should see either a green tick (meaning no errors)

or a count of all the errors, warnings, typos:

Clicking on them will open a section where you get detailed information on each item, their location and recommendations on how to fix them:


Looking for PHP, Laminas or Mezzio Support?

As part of the Laminas Commercial Vendor Program, Apidemia offers expert technical support and services for:

  • Modernising Legacy Applications
  • Migration from any version of Zend Framework to Laminas
  • Migration from legacy Laminas API Tools (formerly Apigility) to Dotkernel API
  • Mezzio and Laminas Consulting and Technical Audit
  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>