VS Code unable to use PHP Intellsense

Viewed 1207

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.

2 Answers

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.

Related