vscode-laravel-extra-intellisense icon indicating copy to clipboard operation
vscode-laravel-extra-intellisense copied to clipboard

No Autocomplete Suggestions for Variables in blade.php files

Open AlexJames-Dev opened this issue 4 years ago • 4 comments

Hello,

I'm not sure if this is a bug or this is not a feature of this extension, but in my blade files, when I write a variable that I have used before in the blade file, I do not get auto suggest completion for the variable. For example:

@foreach($bookings as $booking)
                <td>{{ $booking}}</td>
@endforeach

In this block of code, in an IDE like PHPStorm i would get the autocomplete in the curly braces for the $booking variable. If this is not a feature of this extension, do you know of any that provides this functionality?

Many thanks

AlexJames-Dev avatar May 31 '21 19:05 AlexJames-Dev

@AlexJames-Dev Hello there

No, this extension does not support this feature as no code parser used. Currently, you may provide autocomplete manually using this configuration

"LaravelExtraIntellisense.modelVariables": {
    "booking": "App\\Models\\YourModel"
}

amir9480 avatar Jun 01 '21 05:06 amir9480

I am using type-hinting directly in blade templates (it worked correctly in PhpStorm), something like this:

<?php /** @var \App\Models\IpAddress $item */ ?>
<?php /** @var \App\Models\Range $range */ ?>
<div class="name">{{ $item->name }}</div>

It would be much better than defining types in configuration. And it can be parsed only with regex.

kluvi avatar Apr 15 '22 11:04 kluvi

@amir9480 That would work the same as it does in PHPStorm and would be really nice. I will try using the json config provided, but I will help showing some code we are used to see in blade components. The idea like @kluvi said is to parse the PHPDoc declaration. Thanks for your time!

@php
    /** @var \App\Models\Project $project */
@endphp

@forelse ($projects as $project)
    <x-table.tr>
        <x-table.td>{{ $project->name }}</x-table.td>

I am using type-hinting directly in blade templates (it worked correctly in PhpStorm), something like this:

<?php /** @var \App\Models\IpAddress $item */ ?>
<?php /** @var \App\Models\Range $range */ ?>
<div class="name">{{ $item->name }}</div>

It would be much better than defining types in configuration. And it can be parsed only with regex.

Did you install some extension to make this work? Cause I have annotations in the blade files for all variables, but neither 'jump to' nor autocomplete works for me.

vgaldikas avatar Jun 25 '23 04:06 vgaldikas