Search code examples
phpautocompleteeditorvisual-studio-code

Visual Studio Code PHP autocomplete on external librarys


I use the IDE Visual Studio Code to write scripts in PHP. To write plugins in PHP for a store system, I need to add an external library to my worktree. I have already cloned the library from github and added the folder to my workspace where I am working on the plugin.

The problem is that my IDE still gives errors that namespaces and classes can't be loaded because, for example, there is no namespace with that name. I also can't use the autocomplete feature.

Can someone explain me how to fix this problem?

Screenshots: Undefined Type [...]


Solution

  • I have solved this problem now! To fix this problem I needed the vscode plugin "Intelephense".

    In VSCODE: right click on the folder where the interface must be used and click on "Folder Settings". In the second row under the intelephense extension the radio button "Intelephense > Environment: Include Paths" is shown. There I had to add the path to the interface.