Php-language-server: Remote PHP Interpreter from Docker Container

Created on 9 Dec 2017  路  8Comments  路  Source: felixfbecker/php-language-server

Hi,

Will it be somekind of problem to reproduce the thing that I can find only releated to PHPStorm: https://blog.jetbrains.com/phpstorm/2016/11/docker-remote-interpreters/

That's what I'm missing in my VSCode PHP Intelisense package.

Most helpful comment

You can easily set up a script that runs php from a docker container and point the plugin at that. You do need to mount your home folder into the PHP container (this is for Linux, so YMMV)

#!/bin/bash

docker run --rm -i \
  -v /home/cardonator:/home/cardonator \
  -v $PWD:/code \
  -w /code \
  php:alpine php "$@"

All 8 comments

You can easily set up a script that runs php from a docker container and point the plugin at that. You do need to mount your home folder into the PHP container (this is for Linux, so YMMV)

#!/bin/bash

docker run --rm -i \
  -v /home/cardonator:/home/cardonator \
  -v $PWD:/code \
  -w /code \
  php:alpine php "$@"

@cardonator May u explain me what $PWD stands for and last line: php:alpine php "$@"

I work on WSL on Windows at work and macOS at home.

$PWD is the current working directory on the host machine. In the context of VS Code, it would end up being your workspace project folder.

The last line is what is passed to the docker container. in this case:

php:alpine is the image name

php is the program name to run inside the container.

"$@" essentially means "pass all additional parameters from the command in here.

I have this bash script in /usr/local/bin/php so from the command line I can just run php and it executes that code. I haven't tested it on Windows, but some variation of it should work on macOS.

FWIW, I still think tighter integration between this plugin and the Docker plugin would be a great feature.

It works, as you said - but, yeah. It would be a cool feature to have :)

The language server is available as an image on Docker Hub: https://hub.docker.com/r/felixfbecker/php-language-server/

It speaks LSP and the language server is capable of receiving file contents remotely through the protocol.

Does the vscode-intellisense plugin have the capability to connect to the docker language server?

No, because vscode does not implement the remote files LSP extension.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixfbecker picture felixfbecker  路  7Comments

samurai00 picture samurai00  路  5Comments

adevade picture adevade  路  5Comments

sebet picture sebet  路  6Comments

w0rp picture w0rp  路  9Comments