2

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.

Emanuele
  • 21
  • 2

1 Answers1

1

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!

M.Imran Mamda
  • 394
  • 1
  • 2
  • 13
  • Hi, adding this snippet after the main {} block produces an EOF expected error. – Daniele Jan 24 '23 at 11:07
  • You should not add this after the main {} block, the whole `.vscode/settings.json` file should act like a complete json. My file consisted only of the code I provided above, hence it worked. – M.Imran Mamda Jan 25 '23 at 04:09