I want PHPdoc blocks were considered within the blade template.
PhpStorm 9, Laravel 5.1, blade template file:
<?php
/* @var App\Models\User $user */
?>
...
<?= $user->email ?> <- autocomplete for the word "email" is working
...
{{ $user->email }} <- autocomplete not working
I tried different variants:
{{
/**
* @var App\Models\User $user
**/
}}
{{ /* @var App\Models\User $user */ }}
...
{{ $user->email }} <- autocomplete not working...
...
In such variant autocomplete works, but only within that block:
{{
/* @var App\Models\User $user */
$user->email
}}
...
{{ $user->email }} <- here does not work again...
How to make the autocomplete worked in all blocks for blade templates?
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:
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/
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
More or less same answer, just wrapped in a blade directive:
@php /** @var App\Models\User $user */ @endphp
{{ $user->email }}
来源:https://stackoverflow.com/questions/34131021/how-i-can-make-variables-autocomplete-in-the-phpstorm-9-for-blade-templates