amir9480 / vscode-laravel-extra-intellisense

This extension adds extra autocompletion for laravel projects to VSCode.
https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense
MIT License
3.31k stars 54 forks source link

No Autocomplete Suggestions for Variables in blade.php files #50

Open AlexJames-Dev opened 3 years ago

AlexJames-Dev commented 3 years ago

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

amir9480 commented 3 years ago

@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"
}
kluvi commented 2 years ago

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.

devsquad-eduardo-barijan commented 1 year ago

@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>
vgaldikas commented 1 year ago

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.