The Step-By-Step Guide for Setting up PhpStorm for Magento 2 Development

One of the most important tools for quality developments in Magento is PhpStorm:

  • “Intelligent coding assistance.”
  • “PHP IDE that actually ‘gets’ your code.”
  • That’s what PhpStorm is for developers.

Maybe you've already read a lot on the topic, but we've gathered our real experience and aggregated it into this post for you. Below are some key tips and tricks for configuring PhpStorm to help make your developments in Magento 2 easier and more enjoyable.

Use Static Code Analysis

Magento 2 includes a ready-made set of rules and standards for Code Sniffer (phpcs) and PHP Mess Detector (phpmd).

Use these tools to validate code against Magento 2 coding standards without even running it. You can expect the following results:

  • high validation speed
  • code validation on-the-fly.

Learn more about Magento 2 standards at: Magento 2 Developer Documentation.

Configure your Magento 2 Code Sniffer correctly

Code Sniffer validates the code against standards of formatting, availability and accuracy of comments arrangement, etc.

You can find the file with the rules set in magento/magento-coding-standard/Magento2/ruleset.xml

phpCS Configuration

To include the rules set into a Code Sniffer project, follow these simple 6-step PhpStorm Magento 2 setup instructions:

  • Go PhpStorm -> Preferences
  • In the left menu, choose Inspections in the sub-menu Editor
  • Find PHP -> PHP Code Sniffer validation in the list
  • Turn Validation On
  • Choose the Coding Standard -> Custom and click “ … “
  • Now choose the directory magento/magento-coding-standard/Magento2/

Congratulations! You did it!

But how can you check to see if it's working fine? If you have configured all settings properly, you will see the following result:

phpCS Highlight

P.S.: If you have not configured PhpStorm previously, you need to specify the direct destination of the phpcs. You can do this in the menu item PhpStorm -> Preferences -> Languages & Frameworks -> PHP -> Code Sniffer. Here you should specify the destination to the file in the Development Environment section.


Also, you can try to use PhpStorm to format code automatically. It can greatly speed up the process if you have a lot of files that were formatted incorrectly.

Use PhpStorm Mess Detector to detect possible errors and complications

PHPMD also executes the static code analysis. However, it is more aimed at detecting possible errors and too complicated for interpretation code fragments (classes, methods).

According to our experience, if your code passes all tests and validations (particularly regarding compliance with the rules CyclomaticComplexity, NPathComplexity, CouplingBetweenObjects), then it is easy to read and test, and it contains fewer potential errors.

The Configuration process of the PHP mess detector in PhpStorm is similar to the Code Sniffer setting up procedure, except for the rules set file: dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml

If you have done everything accurately, you will get the result from the screenshot below:

phpMD Hightlight

Use XML Schema Validation to avoid errors in XML files

Unlike Magento 1, every XML file in Magento 2 (layouts, etc/*) must comply with XSD schemas. If any error occurred while XML files editing process, PhpStorm will show it:


It’s a good habit and practice to perform checking for errors in XML files.

To use this feature, execute the following command in ssh terminal: bin/magento dev:urn-catalog:generate .idea/misc.xml

Most IDEs does not support Uniform Resourse Names (URN) by default. If you need to reference XSD schema (that are referenced as URNs) and see it highlighted you need to use following command:

bin/magento dev:urn-catalog:generate

Use Excluded Directories to boost performance

In the development process, PhpStorm regularly indexes all project files and their changes. This action is important for building relations between classes and for autocompletion.

Still, every project includes lots of files which are not necessary to index. Furthermore, the exclusion of those files allows you to increase PhpStorm performance in everyday activities. You need to understand PhpStorm indexing settings in order to configure your dev environment effectively.

We recommend that you exclude the following directories:

  • /bin/
  • /dev/
  • /pub/
  • /setup/
  • /var/cache/
  • /var/log/
  • /var/page_cache
  • /var/view_processed

Follow these instructions to exclude suggested directories:

Excluded directories

That's it! Now your basic configuration of PhpStorm is ready. We hope our experience, tips, and tricks on this process helped you pass it easily and enjoy your developments.

Usage of PhpStorm in Magento development can greatly improve your productivity. Share your thoughts in the comments below and have a nice coding!

What is PhpStorm in 2023?

Since 2020, there have been several updates to the PHPstorm toolbox. It started as a simple IDE that checked if your code was correctly written and up to par with the market standards. Now, the program has grown into an advanced set of instruments, including AI assistance, UI makeover, and multiple supported code languages and platforms. But let's slow down a little.

Three core PHP Storm features haven't changed:

  • Cross-platforming. The current version of IDE is available on MacOS, Windows, and Linux. All variants are fully identical in functionality and can be used interchangeably. This means you won't have any problems transitioning from, say, PhpStorm Mac to PhpStorm Linux.
  • Corrections. PHP editor environment shows you potential errors and helps you correct them. It tracks the usage of variables and functions and matches syntax to the chosen platform standards.
  • Assistance. PhpStorm offers not only the correction of factual mistakes but also advises on code quality. It will tell you if the code is clumsy or can potentially cause problems.

However, there are many new additions to the toolbox.

Big new features of PhpStorm

Rewriting the entirety of patch notes to show new features would be unprofessional. Instead, let's boil down all additions into five key points:

  • UI design. In 2022, the entire interface of the IDE was reworked for convenience and style. It became more minimalistic and enabled a dark theme that is easier to look at for the eyes. The UI continued to improve in 2023, adding compact mode, project tabs, and redesigning widgets. PhpStorm is now more comprehensive and aesthetically pleasing.
  • Quality of life. User experience was improved not only with the new UI. Developers added more color coding and features like zoom, layouts, extended search, pins, clickable paths, etc.
  • Performance. The efficiency of the program was also boosted. Inspections have become quicker, index scanning now uses cache, and popular PHP packs are pre-indexed. The annotator also stays active while indexing is in process.
  • AI support. Update 2023.2 brought with itself AI support. This feature is in the testing phase and has limited access, but it already provides much functionality. The AI assistant can generate documentation and commit messages, explain code, and find problems. You can also chat with the AI to ask it specific questions.
  • Integrations. PhpStorm is now integrated with tools like Prophecy, Laravel Pint, Qodana, and Robo. It works with platforms such as GitHub. External add-ons and formatters are also supported.

These are not all changes, not even the majority of them. However, even this list shows how much work was put into the IDE for the past years.

Elevation: PHPstorm plugins

The PhpStorm free plugins are another way to increase the program's usability. Plugins can be downloaded from the marketplace. They are third-party or "home" software that adds new features, changes UI, language, etc. Using them, you can customize PhpStorm for your personal needs. Below, we compiled a short list of the most popular plugins according to users.

User’s choice plugins for PHPstorm

Kotlin, Bash, and Dart provide support for corresponding coding languages. They add syntax reading and assist with formatting, completion, and navigation. While these plugins are not the only ones that add support for other programming languages, they are the most popular.

The Rainbow Brackets add-on improves the readability of the code by adding more color to it. The plugin can paint brackets, variables, tags, and other elements. It has a set of default colors, but you can customize it.

CSV Editor and .env files support enable PhpStorm to interact with corresponding files. CSV Editor also adds color-coded tables and highlights, checks syntax, and allows customization.

Key Promoter X helps users learn keyboard shortcuts by displaying them when certain actions are made. For example, if you open the "Projects" tab with the cursor, it will tell you that instead, you could've pressed "Alt+1".

The IdeaVim plugin adds support for the Vim engine and its features. It includes different work modes, registers, motion keys, Ex commands, etc. With this add-on, you can even install Vim plugins.

Effective PHPstorm Magento usage

While usage of the Php Storm Magento itself is a wise thing to do, you still may need some tips and tricks to achieve peak efficiency. And these tips are for the user, not the program. Here are four tips to improve your personal skills and be more productive with the PhpStorm:

  • Learn shortcuts. You will perform certain actions daily, if not every hour. For example, changing project tabs or creating new files. Doing these actions with corresponding keyboard shortcuts will gradually speed up your work. One saved second may seem unimportant, but these seconds tend to build up.
  • Use all features. PhpStorm Windows, Mac, and Linux features many useful functions. Advanced search speeds up navigation. Sources of classes or methods can be viewed in the pop-up window. Templates allow you not to waste your time writing the same code from scratch. You just need to use the tools that IDE provides.
  • Add plugins. Customize your development environment with plugins and make it right for your needs. Add support for crucial coding languages, change UI, and bring in automatic actions or new templates. If PhpStorm is nutritious bread, plugins are its butter.
  • Leave comments. Add your own documentation or use the automatic PHPDocs feature to create it. Even if you are working on the project alone – you will thank yourself fot this later. Without documentation, even the most clean and simple code can be confusing.

Modern alternatives

The PhpStorm is not the only IDE in the world. Here are three alternatives for PhpStorm that can also interest you.

Apache NetBeans

This free, open-source IDE is available for Mac, Linux, and Windows. It offers smart editing tools with formatting and highlighting and supports different coding languages. Apache NetBeans is also integrated with Git. The open-source nature of this IDE means that there are plugins to enhance its functionality. The weakest spot of the Apache NetBeans is its somewhat outdated UI design.


The main feature of this cross-platform IDE is an extensive autocompletion tool for many coding languages. It can complete functions, tags, attributes, and more. CodeLobster has free and paid professional versions. This environment also supports third-party plugins and provides all the basic functions of a modern IDE.

Zend Studio

Zend Studio is a paid IDE with a free 30-day trial. This environment provides smart coding assistance, local or hosted debugging and profiling, and support for Git, Docker, and Eclipse. However, add-on options are limited, and the UI is outdated.

Oleksandr Drok

Head of Products at Mirasvit

Alex serves as the Head of Products at Mirasvit, where he formulates the vision for Mirasvit's extensions, carefully curates new features, and constructs the roadmap.
Related Products
Health & Performance Monitoring Suite M2

The Extension monitors code and configuration changes of your store, and automatically notifies you if these changes have negatively affected the key store indicators. If you change anything and find that either your store begins to work more slowly, or you suddenly experience new errors occurred, the extension will quickly notify you about it.