Autocompletion or ability to middle-click follow strings representing files

I have a class that a mostly HTML view file. It's looks like this:

$this->makeView('login_view.php');

The php file is referenced only by a string and phpstorm just treats it like a normal string, so I do not get any special ability to follow it or autocomplete.

Is there a way to have:

1) makeView autocomplete from available view files, for example, in a /view folder (or any or all folders)?
2) be able to middle click to go to (or otherwise access more easily) login_view.php?

I realize this is probably tricky but I had to ask since if there were a way, it would save me a lot of time, especially during refactoring.

2 comments
Comment actions Permalink

Hi there,

Completion -- not possible unless you manually inject "File Reference" in it:

1) $this->makeView('[CARET_HERE]');
2) Alt+Enter
3) Choose "Inject Language / Reference"
4) Choose "File Reference"

Now on Ctrl+Space IDE will look for files relative to Project Root or any folder that is marked as Resource Root.

Ctrl+Click (that's a better known shortcut compared to Middle-Clcik) is possible if you install "Navigate From Literal" plugin (work fine for me)

0
Comment actions Permalink

The Navigate From Literal plugin is great - thanks for suggesting it!

I actually don't use the full file name, but may have to change my code to use it since it would actually make development faster with this plugin.
I instead use this:
$this->makeView('login'); (which finds the file in the appropriate place after appending "_view.php")

instead of:

$this->makeView('login_view.php');

But wrote the latter because it was clearer. Any chance that something exists that can accomodate code like this? I doubt it, but I have to ask.

On injecting a file reference, I tried that, and my code turned red (in the darcula theme) and phpstorm recognized it as an injected file reference, but I couldn't tell what it actually did besides the color change. There didn't appear to be any additional autocompletion. How does an injected file reference work? (I have not used injected languages feature before.)

0

Please sign in to leave a comment.