4

I have been working on learning laravel. I am using Homestead in conjunction with virtualbox - and my IDE is vscode. I have been getting the "problem lines" under inane things in my IDE... see below: enter image description here

I cant figure out why something like "view" or "isNot" has those error lines. Everything works fine I am just wondering why the IDE is throwing intelephenser(1013) problems at me.

Here is the errors it is throwing: enter image description here

Any ideas on getting rid of this would be appreciated! :D

Jacob Downs
  • 51
  • 2
  • 4
  • I've found that Laravel doesn't play well with Intelephense, but using https://github.com/barryvdh/laravel-ide-helper helps with a lot of those errors. – Tim Lewis Nov 27 '20 at 19:35
  • 2
    also the method is `isNot` not `isNOt` – lagbox Nov 27 '20 at 19:36
  • If the answer below worked for you, please set it as "the answer" to close of your question – N69S Sep 15 '21 at 09:29

2 Answers2

5

Laravel has global helper function and class aliases declared

You can use barryvdh/laravel-ide-helper to help your IDE recognize the helpers and aliases.

Follow this guide if you struggle installing it.

basicly

$ composer require --dev barryvdh/laravel-ide-helper

$ php artisan ide-helper:generate
$ php artisan ide-helper:meta
$ php artisan ide-helper:models --nowrite
N69S
  • 16,110
  • 3
  • 22
  • 36
2

Add annotation to your variable like so:

/** @var \App\Models\User $user **/

$user = Auth::user();

It'd tell PHP intelephense that $user variable is not Illuminate\Foundation\Auth\User but \App\Models\User.

Ref: https://stackoverflow.com/a/69580333/11297747

free2idol1
  • 174
  • 1
  • 3
  • 12