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

At the moment (December 2015) 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

UPDATE:

The aforementioned WI-26501 ticket was implemented in 2017 and you can now use PHPDoc comments to declare variables and their types in Blade files.

Be it PHP code blocks:

<?php
/** @var \App\Models\User $user */
/** @var \App\MyService $someService */
?>

... or Blade-specific syntax (@php ... @endphp):

@php /** @var \App\Models\User $user */ @endphp

See the following blog post for details: https://blog.jetbrains.com/phpstorm/2017/02/code-completion-in-laravel-blade-templates/

enter image description here


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/


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

 @php /** @var App\Models\User $user */ @endphp
 {{ $user->email }}