Search code examples
phpconfigurationphpstormwindows-subsystem-for-linuxphpstan

How to run PHPStan in PhpStorm on Windows through WSL?


I run PhpStorm 2023.1 on Windows 11. On the Windows machine, I have an Ubuntu WSL enabled, so that I can develop a PHP project, which works fine.

Now I wanted to enable PHPStan support yet I get the error:

phpstan: 'php' is not recognized as an internal or external command, operable program or batch file.

In the PHPStan settings within PhpStorm I have added the WSL config, and it validates:

Screenshot of PHPStan run config

I wanted to remove the System PHP config, yet the option is greyed out:

the invalid PHPStan config for system PHP

How to enable PHPStan support here?


Solution

  • What do you have for PHPStan at:

    Settings/Preferences | PHP | Quality Tools | PHPStan?

    Have you tried selecting the correct PHP interpreter there?

    If you did and that still does not work then please do the following: make sure that this "Ubuntu-22.04" PHP interpreter is selected as default for this project and then use: By default project interpreter in PHPStan config at the aforementioned place.

    enter image description here


    Regarding System PHP removal. It is not possible to do that right now (latest stable PhpStorm 2023.2.3 version).

    Watch for issues WI-70523 and/or WI-56550 tickets (star/vote/comment) to get notified with any progress.