Edit in GitHubLog an issue

Coding standards

Like many large projects, Adobe Commerce and Magento Open Source have coding standards. Use the coding standards when you contribute to the codebase or create extensions.

Ensuring the code is compliant

You can perform Magento Coding Standard inspection with the Magento2 PHP_CodeSniffer standard.

To execute the inspection from the command line, run the following command from the project root:

Copied to your clipboard
vendor/bin/phpcs --standard=Magento2 <path to inspect>

To include the Magento Coding Standard as part of PHPStorm inspections:

  • Open PHPStorm preferences
  • Navigate to "Editor" | "Inspections"
  • Select "PHP" | "Quality Tools" | "PHP_CodeSniffer validation"
  • Set "Coding standard" to "Custom" and select the path to <project_root>/vendor/magento/magento-coding-standard/Magento2/ruleset.xml
  • Check "Installed standards path" and select the path to <project_root>/vendor/php-compatibility/PHPCompatibility

Contributing

The Magento Coding Standard is created and maintained by the Magento community! See the Contribution guide if you'd like to participate.

Review the standards

Standard details and guides:

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.