Undefined Type on Namespace using Intellisense

998 Views Asked by At

I got undefined type on my project when addressing classes autoloaded with composer json.

this is the extract of my composer.json file

"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Shared\\": "../Shared/"
    },
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "files": [
        "app/helpers.php"
    ]
},

The auto-complete doesn't recognize anything inside Shared.

In the LanguageServer Log i found that vs-code parsed all autoload files correctly.

This is a problem related only on vs-code and intellisense/intelephense; when I run the project all work like a charm.

Any help would be appreciated.

1

There are 1 best solutions below

2
On

Just add this below json value in .vscode/settings.json file:

{
    "intelephense.environment.includePaths": [
        "../Shared/"
    ]
}

Not only the error disappears, but also the code completion starts to work!