Skip to content

A method to generate file links, akin to xdebug.file_link_format? #50

demonkoryu opened this Issue Jan 9, 2013 · 5 comments

3 participants


With xdebug, I can define a format for links to the filename/line number of the call stack, for example:

xdebug.file_link_format="javascript:var d=document,r=d.createElement(\"script\");r.src=\"http://localhost:8091?message=%f:%l\";d.body.appendChild(r);void(null)"

Here, the generated links allow me to click to open the file in question directly in IntelliJ IDEA. Is it possible to preserve the link format, or maybe use the xdebug.file_link_format ini setting to format it that way by yourself?


I greatly second this feature and miss this the greatest! For TextMate I use
xdebug.file_link_format = "txmt://open?url=file://%f&line=%l"

@markcarver markcarver added a commit to markcarver/PHP-Error that referenced this issue Jan 13, 2013
@markcarver markcarver Fixes #50 - A method to generate file links, akin to xdebug.file_link…

I fully agree this idea should be in, however I do not agree with the approach. Here is my thinking.

by default, detect the editor to use

If I am using IntelliJ, then it should open in IntelliJ, automatically! No urls, no having to build this prefix, it should just work, out of the box. Same if I am using Textmate, Sublime, gVim, Eclipse, PHPStorm, NetBeans, Visual Studio, etc. They should all be supported, automatically, with no setup required.

That will work if the editor is currently open, by looking at the currently running processes.

also allow specifying the editor

What if an editor is not open, or I want to specify it? Then you can use 'file_link_format' to override, and set it manually. First we'll support urls, such as those you two have provided.

However I do not want to have to do:

file_link_format = txmt://open?url=file:// ... etc

However I find that too much, and I certainly couldn't remember that. So shortcuts will also be provided, allowing you to just do:

editor = textmate
editor = sublime
editor = "visual studio"
editor = intellij
editor = gvim

You then get a way to open the file, given to you automatically. If an editor is not supported, it should raise an error.

If both of those fail, it will just use a 'file://c:/my_website/file.php' type url.


I'm all for that. I have a question, though: How would my web server know which IDE I'm currently running? In my case, the web server runs on another box.


I kind of have to agree here, how would my browser know what program I use? Even if you were to use just the file:///, the browser may just display it instead of sending to another program. I mean yeah, you could have a daemon that handles sending files to an editor and namespace links to something like phperror://. When the browser encounters it, you simply tell it to use the daemon, but that seem like more work and is certainly not [initially] automatic as you'd have to let the browser know where the daemon is.


If it's on another box, then you would set file_link_format.

However a lot of devs use XAMPP, or something similar for development, and that is why I'd prefer a solution that "just works", for those occasions, and does nothing, where that will not work. This will do both.

We can know what editor you are using, by using exec to get a list of running processes. If Sublime/Textmate/whatever is in the list, then it must be running on the same machine it's being developed on, and that will be editor. If it doesn't, then it doesn't do that.

A generic 'file://' is also only given, as a generic default, when all others fail.

It might be worth calling the 'editor' option 'local_editor', to point out that it would only be designed to work locally.

Finally to clarify, the order of things to use when generating the link would be:

  • check if file_link_format or local_editor is set, and use that
  • check if a known editor is running on the same machine, and use that
  • use file://
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.