Missing Twig Template in PhpStorm with Symfony Plugin

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

The template link works fine for template files placed under app/Resources/views , but not for files placed under Bundle/Resources/views .

Here is a screenshot. As you can see, in the first line there is no warning that refers to the test.html.twig file placed in the app/ directory, but it warns about templates that are placed in the package resources.

The code works well, and the package templates are displayed in the browser.

enter image description here

Symfony Plugin Configuration:

enter image description here

+10
source share
3 answers

I had the same issue with Symfony3 and Symfony4 . The fix is ​​really simple.

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

Twig namespaces settings

+11
source

I had the same problem, but I did not want to answer @Andrey Rudenko because I would lose all the configuration specific to my project. Instead, I followed @COil's comment and jusnt invalidated my cache and the problem was resolved.

 File -> Invalidate Caches / Restart -> Invailidate and Restart 
+3
source

Just the same problem. I upgraded from Symfony 2 to Symfony 3 , and it looks like a crash in PHPStorm with the old project file. Just delete the .idea folder and create the project in PHPStorm from the "existing files", which will lead to the creation of a new project with the default setting, but the failure will disappear.

Also remember that by deleting the .idea folder, you will lose the entire project configuration.

0
source

Source: https://habr.com/ru/post/1242073/


All Articles