[xdebug-general] Firefox, VIM, Xdebug: Jumping to the error line.

From: Thomas Koch <thomas[@]koch.ro>
Date: Sat, 7 Jun 2008 17:55:29 +0200

source:
http://www.koch.ro/blog/index.php?/archives/77-Firefox,-VIM,-Xdebug-Jumping-to-the-error-line..html

The yet unreleased 2.1 version of XDebug has a nice new feature. The setting

xdebug.file_link_format

allows you, to provide a printf like format for a link under the filename of
an error message.

So here comes a quick walkthrough on how to open the file from the error
message in (G)VIM:
First we need to tell the browser, in my case firefox, that the link is no web
link, but should be threaten special. We do this with the introduction of the
new protocol "vim://".

Put this setting in your PHP configuration:
CODE:
xdebug.file_link_format=vim://%f@%l

Now instruct firefox which program handles the protocol. Therefor you need to
open the about:config page and add two settings:
CODE:
network.protocol-handler.external.vim boolean true
network.protocol-handler.app.vim string
~/bin/ff_xdebug_gvim

The ff_xdebug_gvim file is a script that parses the link and calls gvim with
the appropriate parameters:
CODE:
#!/usr/bin/env php5
<?php
// cut the vim:// prefix from the input.
$input = substr( $argv[1], 6 );

// split the filename from the line number, separted by '@'
// filenames could come in urlencoded
$delimiterpos = strrpos( $input, '@' );
$file = urldecode( substr( $input, 0, $delimiterpos ) );
$line = ( string )( int )substr( $input, $delimiterpos - strlen( $input ) +
1 );

// --remote-silent opens an already running gvim session or creates a new one.
Replace gvim with
// vim if you like!
system( 'gvim --remote-silent +'.escapeshellarg( $line ).' '.escapeshellarg(
$file ) );

That's it. Thanks for your patience.

And as usually: Restart your webserver and chmod +x the script.

-- 
Thomas Koch, Software Developer
http://www.koch.ro
Young Media Concepts GmbH
Sonnenstr. 4
CH-8280 Kreuzlingen
Switzerland
Tel    +41 (0)71 / 508 24 86
Fax    +41 (0)71 / 560 53 89
Mobile +49 (0)170 / 753 89 16
Web    www.ymc.ch
Received on Sat Jun 07 2008 - 18:25:17 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST