DEV Community

Cover image for How to Enable Autocomplete in Laravel Blade Views and Partials
Raheel Shan
Raheel Shan

Posted on • Originally published at raheelshan.com

How to Enable Autocomplete in Laravel Blade Views and Partials

Blade is messy. Laravel developers throw arrays into views and call it a day. I wasn’t interested in that. I wanted typed views with proper autocomplete, and I wasn’t going to settle until Blade behaved like the rest of PHP.

Laravel developers are used to Blade being loose. Developers pass some data to blade views from the controller and hope to remember the property names. IDEs like Visual Studio throw their hands up in frustration, and the best you get is Laravel Intellisense or Laravel Intelliphence that work well with php context but fail within blade views.

I wasn’t okay with that because just like the other parts I wanted proper autocomplete in Blade templates, the same way I get it in my PHP classes. And the solution meant ditching the usual suspects and moving to something better.

Why I Dropped Laravel Intellisense and Intelliphence

Both of those packages try to patch Blade typing from the outside. They work, kind of, but they're shallow. Autocomplete is hit-or-miss, and partials are basically left out in the cold. If you’re serious about typed views, these tools will only get in your way.

Enter PHP Tools by DevSense

This is where things got interesting. PHP Tools by DevSense is an extension that actually treats Blade files as first-class citizens. It doesn’t guess at variables. it lets you declare them explicitly at the top of your view or partial, and from there you get full, proper autocomplete.

@php
    /** @var \App\ViewModels\HomeViewModel $model */
@endphp
Enter fullscreen mode Exit fullscreen mode

And here's the output.

Autocomplete in blade views

Autocomplete in Partials Too

This isn’t just for full-page views. I applied the same approach to partials. All I do is define the class at the top of the partial:

@php
    /** @var \App\Models\Post $model */
@endphp
Enter fullscreen mode Exit fullscreen mode

Autocomplete in blade partials

And boom. Now partials behave like typed components. No more “which fields were passed into this include again?”—the IDE tells you, loudly and clearly.

And now suddenly, the Blade views became typed. Controllers must hand over the correct ViewModel, and partials must receive the class they’re expecting. This is how you get predictable, maintainable views.

Why This Matters

Typed views aren’t about being fancy. They’re about discipline. Blade is where most Laravel apps quietly rot: arrays of random data passed around until no one remembers what’s required or safe to use. Using autocomplete feature and strict typing you force your balde views to behave properly. You know what’s available. The IDE knows what’s available and the code complains if you try to cheat.

Final Thoughts

So, yes, I had to drop Laravel Intellisense and Laravel Intelliphence. They weren’t built for this. PHP Tools by DevSense is. It gave me the autocomplete I wanted and the typed discipline my Blade views desperately needed.

If you’re tired of Blade being a guessing game, it’s time to try it yourself.

This is part of my bigger effort to bring structure to Blade using ViewModels and typed partials. If you like this approach, check out my other posts where I go deeper into why Laravel views need discipline.


If you found this post helpful, consider supporting my work — it means a lot.

Support my work

Top comments (0)