https://stackoverflow.com/questions/53501925/visualstudio-code-php-executablepath-in-docker
Add a bat file that passes the php command to the docker container :)
@echo off
sail php %*
Summer Sale! All accounts are 50% off this week.
So, I just setup a fresh project with Laravel Sail. (Windows 10, WSL2, Docker)
Everything are running perfectly. But, in VSCode the PHP Language Feature requires php.validate.executablePath in settings. How to put the PHP path from Docker in this settings.
And, also PHP is not installed in WSL. When, I run php -v in WSL it throws Command not found. But, sail up works fine. (It Seems to be running standalone, so how to get the executable path???)
I came up with a solution on Linux for multiple laravel sail projects.
Create a file named 'php' on /usr/local/bin
sudo touch /usr/local/bin/php
Make it executable:
sudo chmod +x /usr/local/bin/php
Edit the file (with sudo) and paste this code:
path=$(printf '%s\n' "${PWD##*/}")
command="docker exec ${path}_laravel.test_1 php "$@""
echo "Running php on docker ${path}_laravel.test_1"
$command
Now just run, example, 'php -v' inside the laravel sail project.
Please or to participate in this conversation.