Reputation: 154
I have Devsense PHP Extension in Vscode and my project is inside the docker container.
I have service named "app" inside my docker compose but specifying php executables like this, doesn't work:
"php.executables": {
"my/sail-php8.2": "./docker/php/bin/php"
}
Inside my ./docker/php/bin/php is like this:
docker compose exec app php "$@"
But somehow running phpunit tests by using this extensions wont work because the output keep showing this command:
php -d display_errors=on /home/erstevn/Code/pilihjurusan/api/vendor/bin/phpunit --teamcity
It means that my php executable path is not what they're using (they use php binary inside my linux instead).
What i'm supposed to do then?
EDIT
Somehow my PHP extension cannot find my customized php version inside the docker container
PHP extension started.
Couldn't resolve requested PHP version 'my/sail-php8.2' ... Using default 'php'.
Found PHP, version: 8.2.3, Xdebug: not loaded.
Upvotes: 0
Views: 839
Reputation: 154
Found out that you have to define full path for the php.executables
so I added this to the User settings.json
"php.executables": {
"custom-php-ver": "/home/(username)/(workspace)/api/docker/php/bin"
}
and then inside your php/bin
file:
cd $(dirname $(readlink -f $0)) && cd ../../ && ./vendor/bin/sail php "$@"
I'm using sail so that would be the php executable. Just in case you may asking what the $(dirname $(readlink -f $0))
do, it's just referencing the php/bin file path that being executed.
I don't want use the pwd
command because the Devtools PHP Extensions will execute the path relative to your home folder so the pwd
will outputs /home/(username)
instead
Upvotes: 0