'VS Code unable to use PHP Intellsense

I want to use PHP IntelliSense while using WSL environment but VScode is unable to find PHP path. What I should do fix this? I searched for some info but I only see scripts but none worked for me.



Solution 1:[1]

Try bash -c "php". WSL exposes a bash.exe binary on Windows, and if everything is correct it will already be in the environment variables, just by invoking it as bash - At least here, where I am using WSL2 with Ubuntu 20.04.

You try also, wsl -- "php" or wsl --exec "php".

UPDATE: Forget what I said above !!

Use the Remote - WSL extension . I believe you're already using it. Add the following directive to the settings.json file: "php.validate.executablePath":"php"

the php binary must be properly available in $PATH on the Linux side.

And on Windows you need to have the path of the php windows version binary in the system environment variables, so that when you happen to be editing PHP files in the Windows File System - Not using the WSL remote - it uses the same binary.

This way you will have a VSCode that, when you are remote in WSL will use the proper lecture, being the same for when you are in Windows.

Solution 2:[2]

The fix for me was to download php for Windows into the folder c:\php and specify in Visual Studio Code settings.json:

   "php.executablePath": "c:\\php\\php.exe",

I also added it to my Windows PATH environment variable.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zymotik
Solution 2 Zymotik