PatrickB
PatrickB

Reputation: 3255

IntelliJ and xDebug - xdebug.file_link_format

I've searched much time about IntelliJ IDEA 12 and the xdebug.file_link_format configuration value.

I found nothing which works...

Is it possible to use the xdebug file links with IntelliJ IDEA or PhpStorm?

Upvotes: 4

Views: 3331

Answers (5)

LazyOne
LazyOne

Reputation: 165118

Yes and No.

No -- there is no proper built-in support for this. Watch this ticket for details: http://youtrack.jetbrains.com/issue/IDEA-65879

Yes -- you may find some workaround, at very least the aforementioned ticket has recipes for Mac OS (using AppleScript) or via Remote Call etc.


Update: as of PhpStorm 8 you may use:

xdebug.file_link_format = "phpstorm://open?file=%f&line=%l" 

Upvotes: 8

Charlie
Charlie

Reputation: 9108

The REST API is probably the best option now:

http://localhost:63342/api/file%f:%l

Wrapping in a javascript protocol and AJAX request allows the permission approval to be saved so you don't have to approve every time you click:

javascript: var r = new XMLHttpRequest; r.open('get', 'http://localhost:63342/api/file%f:%l');r.send()

API specs: https://www.develar.org/idea-rest-api/

Upvotes: 0

Szekelygobe
Szekelygobe

Reputation: 2667

You need to ad to the php.ini file in the [xdebug] section the following line:

xdebug.file_link_format = "phpstorm://open?file=%f&line=%l"

Then restart your web server (Apache for me on Mac)

Upvotes: 0

Erik Hansen
Erik Hansen

Reputation: 225

Per the comment from @gapple, this will make Xdebug link to the file/link in PhpStorm:

xdebug.file_link_format = "phpstorm://open?file=%f&line=%l"

I tested this in PhpStorm 10 on Mac and it works great.

Upvotes: 1

Piskvor left the building
Piskvor left the building

Reputation: 92752

Not out of the box, but it is possible to get the links to work. I have this working with Windows 7, Firefox and PhpStorm 10 - in this example, I'm using the protocol phpstorm://, but this will work regardless of the name.

// note: edit the path, with backslashes escaped

var editor = '"c:\\Program Files (x86)\\JetBrains\\PhpStorm 143.434\\bin\\PhpStorm.exe" nosplash --line %line% "%file%"';

var url = WScript.Arguments(0);

var match = /^phpstorm:\/\/open\/\?file=(.+)&line=(\d+)$/.exec(url);

if (match) {

var file = decodeURIComponent(match[1]).replace(/\+/g, ' ');

var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file);

var shell = new ActiveXObject("WScript.Shell");

shell.Exec(command.replace(/\\/g, '\\\\'));

}

  • create the protocol in registry: create the following as editor.reg and import to Registry. Note that you again need to double-escape the path to the above file, and set it to wherever yours is saved:

REGEDIT4

[HKEY_CLASSES_ROOT\phpstorm]

@="URL:phpstorm Protocol"

"URL Protocol"=""

[HKEY_CLASSES_ROOT\phpstorm\shell\open\command]

@="wscript \"C:\\path\\to\\run-editor.js\" \"%1\""

  • enable the protocol in Firefox: in about:config, create a "logical value" named network.protocol-handler.expose.phpstorm and set it to false

  • open one such link in Firefox, e.g. phpstorm://open?file=somefile.html&line=123 - it should open in PhpStorm.

Upvotes: 1

Related Questions