Vscode-intelephense: Undefined type 'DB'. Intelphense (1009) in Laravel 6 Controller

Created on 9 Jan 2020  路  4Comments  路  Source: bmewburn/vscode-intelephense

Describe the bug
It's an unexpected error notice when working with Laravel 6 that Undefined type 'DB'.

Expected behavior
It should not display the error notice.

Screenshots
You can see the error notice screenshot here

Platform and version
Windows 10, 64 bit. Intelphsense 1.3.7

Most helpful comment

Try use Illuminate\Support\Facades\DB; instead of use DB;

All 4 comments

Same issue (or related?) after update to 1.3.7.

Schermafbeelding 2020-01-09 om 21 05 25

@mofizul21 those laravel global namespaced facades like DB don't have a concrete definition in the workspace and cannot be indexed. To get around this you can use https://github.com/barryvdh/laravel-ide-helper or if you prefer set intelephense.diagnostics.undefinedTypes to false in settings.

@mstroink that's a strange one. It looks like it has found the definition to provide the hover. Can you share some code that reproduces the issue?

Closing as original issue has a solution. @mstroink if you are still experiencing this please open a new ticket with a code example.

Try use Illuminate\Support\Facades\DB; instead of use DB;

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muuvmuuv picture muuvmuuv  路  4Comments

zlianon picture zlianon  路  3Comments

umpirsky picture umpirsky  路  4Comments

ottopic picture ottopic  路  3Comments

aleksandervines picture aleksandervines  路  3Comments