Darkdawg's avatar

Autocompletion for public/computed properties in Livewire views?

Looking for extensions/tips to improve my VS Code experience with Livewire 3/4 MFC/SFC.

I'm currently using the MFC/class based approach, but what bugs me the most is that my views have zero knowledge of my classes, so whenever I reference any variable all I get is (global variable) $category even if this is defined as public Category $category in the class.

Not sure if this is any better with the Volt/SFC, but from my brief testing it was the same.

Would PHPStorm come with support for this?

0 likes
2 replies
valentin_vranic's avatar

Well, I'm using PHPStorm, with barryvdh/laravel-ide-helper package. But the experience is somewhere similar you described.

My experience is that, when the view's name is rendered from the convention of class name, it is more reactive on referencing the properties, methods used in view.

The other way, sometimes when it's a bit different named view, it simply doesn't recognize anything.

It would a be a pleasure to have some other insights from others too.

Darkdawg's avatar

Alright, I'm also using the ide-helper package, as well as the official Laravel IDE extension for VS Code (which does mention something about Livewire support in the works). It would be awesome if at the very least public & computed properties would show up.

I feel like sometimes when I watch Youtube tutorials/coding sessions the users get intellisense for their views as well, but it might just be AI code completions, I wish I knew.

I usually opt for the default naming convention myself (whatever comes from the Artisan create command). I didn't notice any difference with one or the other, though.

One recent (beta) extension/package I would definitely recommend looking into is the one Filip Ganyicz is working on. Check out Bond & Livewire SFC/Volt support extension, the latter switches between language mode (PHP/Blade) depending on where you click in a single file component. Last time I tried Volt it was pretty unusable in VS Code, because IDE support was terrible.

Please or to participate in this conversation.