Skip to main content

PHPStorm, Magento & WSL2 Performance

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· 2 min read
Stephan Hochdörfer

Whilst I migrated from Linux to Windows and WSL 2 more than a year ago, I had a plan to install any development-related tools like Git or PHPStorm in WSL2. PHPStorm worked quite ok in WSL 2 except that filesystem changes (e.g. adding or removing files) made directly in WSL 2 were not properly recognized by PHPStorm. Even triggering a manual refresh from the disk did not always work. That made me install PHPStorm on Windows and open PHP projects via the WSL 2 integration of PHPStorm. That works better but still has its issues with larger projects.

After running the setup:di:compile or setup:static-content:deploy tasks in WSL2, PHPStorm reindexes like crazy. And sadly, during a reindexing process, a lot of built-in functionality does not work. The PHPStorm folks advised me to mark some of the directories as “excluded”, specifically the directory where Magento stores its generated data. That does improve things quite a bit. I usually now ignore the following directories:

- generated/code
- generated/metadata
- pub/static
- var/cache
- var/composer_home
- var/page_cache
- var/views_preprocessed

UPDATE: Apparently, PHPStorm and other Jetbrains products have issues with WSL2 communication. When you still feel indexing is not working or just slow, try to disable the experimental feature "wsl.fsd.content.loader" in your IDE. Read here how to do that.
Or as an alternative try using "Gateway" which is another solution by Jetbrains for remote development. In this case, you need to install Gateway in your WSL2 instance and then point your local IDE to the Gateway instance. Find some guidance here on how to configure everything.