Search code examples
phpwindowsvisual-studio-codeintellisenselaradock

Laradock in remote containers with VS code and PHP IntelliSense working


How to setup "PHP IntelliSense" on Visual studio code with Laradock to use the PHP binary in the laradock_workspace_1 container?

I have tried to start Remote-containers: attach to running container..., then problem is I can´t access my git repo since its mounted on Windows.

In Windows I can´t access the PHP binary in the docker container, is it possible for vs code to access PHP some remote way(without open a new vs code in the container), so it will have all libraries and modules loaded. This is something I need to get PHP IntelliSense working in correct way? Now some of the autocomplete are not working for example all functions related to Eloquent.

I have found this but unfortunately I don´t understand how to get it work: https://github.com/laradock/laradock/issues/2248

Any other suggestions on how to get autocomplete to work, without install same PHP version in Windows (I don´t want to pollute my system)?


Solution

  • Start with connecting to the Laradock workspace container (Remote-containers) and mount the folder: /var/www/

    This will allow you to access the files outside the container.

    Then for PHP IntelliSense you should add this line to the settings file:

    {
        "php.executablePath": "/usr/local/bin/php"
    }
    

    It might be possible to export the port to php-fpm outside the container, but nothing I know how to do. You can also connect to the php-fpm container, but I think the workspace is more practical to connect to.