Search code examples
phpstormphpdoc

Creating link to template files in PHPStorm (maybe using PHPDoc?)


I see that PHPStorm has a way to identify templates names inside quoted string so that Ctrl+Click can open the View or Template file in the editor.

I think there is partial support for Blade templates but I don't see a generic way to do this for my own functions.

Here is an example:

enter image description here

Obviously the above does not work but I'm wondering if there is some other way to do it?

Thanks!


Solution

  • Install and use Navigate From Literal plugin -- it works with any strings as it matches files by names.


    Plugin's logic is pretty flexible; but may produce more than one choice in some cases -- depends how many similarly named files are found: it matches by file name and will ignore extension or path (not a big issue -- just one more click, but I have no clue how you/other people will react for this).

    For example, in this case it should be obvious that I want product/range.twig file as it's the only range file in product folder, but plugin thinks a bit differently. In some cases it's good to have such logic, but sometimes it's confuses and does opposite -- you end up opening the wrong file by mistake.

    enter image description here