Autocomplete indexing of vendor folder when using Docker as remote interpreter

We are using docker containers for local development and we are having the trouble of indexing the vendor folder for autocomplete when setting up the container. We use the following tools:

- Pack CLI (https://buildpacks.io/) for orchestrating the build process for the docker image.
- Heroku PHP buildpack (https://github.com/heroku/heroku-buildpack-php) for building the docker image.
- Docker Compose for starting all the services we need, including the web process where PHP and Nginx runs.

Main Issue: Autocomplete doesn't work when launching a docker remote interpreter as run configuration.

Ideally the vendor folder (inside the docker container) should be indexed by the IDE to allow autocomplete to function as expected.

The workaround right now is to either:

1. Copy the vendor folder to the host (not ideal as we need to manually keep in sync when installing new dependencies),

2. Install all dependencies on the host system before building the container (skips composer installing dependencies when running the heroku php buildpack as the vendor folder already exists) or

3. Setup a docker volume and sync the vendor folder between container and host.

However the latter doesn't work if the host vendor folder is empty or does not exist. It simply overwrites the folder in the container and prevents the server from starting.

Is there a way to index the folder in the docker container (docker-compose.yml remote interpreter/run configuration)?

This would really be the missing piece of our setup, as this would mean we won't have to:

1. Manually keep the vendor folder in sync
2. Run `composer install --ignore-platform-reqs` on the host machine that may not have composer.
3. Setup a potentially slow docker volume to sync changes to the vendor folder between the host and container.

I really can't seem to find much on the web about this topic which I was surprised about. Seems like an obvious one to me, but maybe I'm just oblivious and fundamentally missing something important?

This solution would also apply to WebStorm and JavaScript projects where the `node_modules` folder also needs to be indexed from inside the container.

Copying files to the host or syncing them with the host is really not want we want to be doing these days and defeats the point of an isolated development environment. VS Code has an awesome solution to this using the Remote development Extension Pack where the entire project runs in a container and is indexed by the IDE as one would expect. Is there a PHPStorm equivalent?

It would be REALLY awesome to solve this and look forward to your suggestions and solutions.

3

In general, it's this one: https://youtrack.jetbrains.com/issue/IDEA-226455
At the moment, the concept of remote development isn't supported by the platform.
There's Projector, but I am not sure if that's a way you want to go down: https://lp.jetbrains.com/projector/

1

Thanks Eugene Morozov for the info. I wasn't aware of this issue nor aware of Projector. Looks promising, however as mentioned the only thing we are missing is the indexing of the vendor/node_modules folder inside the container. Anything else is just overkill right now :)

3

Are there any news in this topic?

0

Sorry, what news exactly are you interested in? Is it Remote Development? Then you can already try it out: https://www.jetbrains.com/help/phpstorm/remote.html

0

Dmitry Tronin Remode Development is NOT what we want. We have existing projects running "locally" in Docker. These projects have `vendor` or `node_modules` folders. Mapping those folders from the container to host machine via volumes leads to absolutely horrible performance; for example, having a blank Symfony project in Docker with mounted `vendor` folder:
```
volumes:
- ./:/srv/app (this also includes/synchronizes /vendor)
```
leads to every single request taking up 7+ seconds. Even just connecting to the container via SH and executing `bin/console` with no arguments takes 7+ seconds! I have no idea why it takes so long, but unfortunately it does (it's not like it needs to sync the entire vendor folder to host on every command, but it sure feels like that's exactly what it's doing).
However, the moment I exclude `vendor` from this volume mapping:
```
volumes:
    - ./:/srv/app
    - /srv/app/vendor
```
and rebuild, that exact same `bin/console` command takes only ~0.2 seconds. That is a huge performance difference, but it has a major drawback - the vendor folder is now empty and thus syntax highlighting, autocomplete, etc is all broken.

What we need is a way for PHPStorm (and other IntelliJ projects) to map/index this `vendor` folder from inside the container.

There is `Settings > PHP > Path mappings`, but it ignores the `- /srv/app/vendor` entry, and manually adding it does nothing:

All we need is for PHPStorm to index this folder and keep indexing it if something changes, nothing else. It does not need to be synced with the host system (that kills the performance), we do not want to run PHPStorm inside Docker (just why?), nothing fancy. Just make PHPStorm read this (or any other configured) folder.

1

Vasiliy Yur Considering that that task is 5 years old already... I'm not holding my breath.

0

+1 for the problem described by Alex. I stopped by PhpStorm subscription about two years ago due to this (as this is THE main flow these days) and I'm amazed it hasn't been addressed yet.

0

Exact same issue as Juris Sudmalis described, a temporary solution to sync vendor manually.

docker cp <container_id_or_name>:/path/to/container/vendor /path/to/local
 

0

请先登录再写评论。