Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined functions/methods - Intelephense(1013) - Laravel Homestead + VScode

I have been working on learning Laravel. I am using Homestead 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 can't 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 are the errors it is throwing: enter image description here

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

like image 793
Jacob Downs Avatar asked Oct 15 '25 17:10

Jacob Downs


2 Answers

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
like image 177
N69S Avatar answered Oct 17 '25 07:10

N69S


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

like image 25
free2idol1 Avatar answered Oct 17 '25 08:10

free2idol1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!