How I can make variables autocomplete in the PhpStorm 9 for Blade templates?

前端 未结 4 1089
礼貌的吻别
礼貌的吻别 2021-01-02 06:38

I want PHPdoc blocks were considered within the blade template.

PhpStorm 9, Laravel 5.1, blade template file:



        
相关标签:
4条回答
  • 2021-01-02 06:47

    More or less same answer, just wrapped in a blade directive:

     @php /** @var App\Models\User $user */ @endphp
     {{ $user->email }}
    
    0 讨论(0)
  • 2021-01-02 06:54

    ATM PhpStorm does not support PHPDoc comments in blade templates using blade syntax (especially for completing blade variables).

    Please follow these tickets (star/vote/comment) to get notified on progress:

    • https://youtrack.jetbrains.com/issue/WI-26501
    • https://youtrack.jetbrains.com/issue/WI-25287
    0 讨论(0)
  • 2021-01-02 06:55

    You can now do it like you wanted:

    <?php
    /* @var App\Models\User $user */
    ?>
    ...
    {{ $user->email }} <- autocomplete working
    

    see https://blog.jetbrains.com/phpstorm/2017/02/code-completion-in-laravel-blade-templates/

    0 讨论(0)
  • 2021-01-02 07:06

    As of right now this isn't entirely possible due to PHPStorm's lack of support for Blade templates.

    This package may be of some use for other Laravel related issues https://github.com/barryvdh/laravel-ide-helper

    0 讨论(0)
提交回复
热议问题