Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Twig template in PhpStorm with Symfony Plugin

PhpStorm version: 9.0.2
Symfony Plugin version: 0.11.109
Symfony version: 3.0.1

Template referencing works fine for template files placed under app/Resources/views but not for files placed under Bundle/Resources/views.

Here goes screenshot. As you can see there is no warning highlight at first line that references to the test.html.twig file placed under app/ directory, but it warns on templates that are placed under bundle resources.

Code works well and bundle templates renders in browser.

enter image description here

Symfony plugin configuration:

enter image description here

like image 660
Fisher Avatar asked Feb 02 '16 08:02

Fisher


2 Answers

I had the same issue with Symfony 3 / 4 / 5. The fix is really simple.

All you have to do is add the app/Resources/views (or templates in case of Flex) directory manually to Twig namespaces as follows:

Twig namespaces settings

This way you can also support custom Twig namespaces, so PhpStorm can autocomplete those as well.


If it's not working immediately, you should invalidate the cache:

File -> Invalidate Caches / Restart
like image 88
emix Avatar answered Oct 18 '22 12:10

emix


I just had the same problem as well, however I didn't want to follow @Andrey Rudenko's answer because I would lose all my project specific configuration. Instead I followed @COil's comment and jusnt invalidated my cache and the problem was solved.

File -> Invalidate Caches / Restart -> Invailidate and Restart
like image 20
Yep_It's_Me Avatar answered Oct 18 '22 13:10

Yep_It's_Me