PHPStorm autocomplete twig vars PHPStorm autocomplete twig vars laravel laravel

PHPStorm autocomplete twig vars


You seem to be missing the @var annotation.The correct form would be:

{# @var foo \FooService #}{{ foo. }} <!-- press CTRL+SPACE for typehints -->

I got this working for a non-symfony project without issues. Be sure to check that the symfony plugin is actually enabled for the project (it isn't by default) and restart the IDE after you enable it.

Also make sure that the type-hint point to the fully qualified class name.


As a sidenote, I have not (yet) gotten this to work for properties, i.e. foo.bar.* when the property is accessed through magic (using __get). For those instances the property needs to be put into a variable of its own:

{# @var foo \FooService #}{{ foo.bar. }} <!-- no typehints for bar :-( -->{% set bar = foo.bar %}{# @var bar \BarService #}{{ bar.  }} <!-- press CTRL+SPACE for typehints :-) -->