NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

xdebug file_link_format for NetBeans?

 
Post new topic   Reply to topic    NetBeans Forums -> PHP Users
View previous topic :: View next topic  
Author Message
johnkary



Joined: 04 Dec 2009
Posts: 1

PostPosted: Sat Dec 05, 2009 12:27 am    Post subject: xdebug file_link_format for NetBeans? Reply with quote

Working on Mac 10.5.8 with NetBeans 6.8 beta and xdebug 2.0.5.

In php.ini, you can specify the xdebug option xdebug.file_link_format for opening the given file path in your editor of choice if it has a custom URL scheme. With Textmate, you can route files to txmt:// by using...

Code:
xdebug.file_link_format="txmt://open?url=file://%f&line=%l"


1) Is there a file_link_format you can use to open files in netbeans?
2) If not, is a custom URL scheme planned?
3) Is there any other way I can route files to open in netbeans from xdebug browser sessions?


I found this link which shows how you could do it on Windows from the OS-level. Is this possible on Mac OS?

There was also this script which adds a custom network.protocol-handler.app.(PROTOCOL) to Firefox, which instructs it to execute a Ruby script to parse the incoming string and re-route it to the command-line. Netbeans allows you to open files from the command-line and even assign a line number:

Code:
/Applications/NetBeans/NetBeans\ 6.8\ Beta.app/Contents/Resources/NetBeans/bin/netbeans --open /etc/hosts:4


While the above could be used as a work-around for Firefox, it's not the best solution.

Thoughts?
Back to top
nico_somb



Joined: 16 Dec 2009
Posts: 1

PostPosted: Wed Dec 16, 2009 8:55 am    Post subject: Reply with quote

Hi,

unlike you said in your post, it's not possible on windows : the post on my blog you quoted says that I failed...

Is there anyone here who can help me to open netbeans with file_link_format on Windows please ?
Back to top
eleg2



Joined: 12 Feb 2010
Posts: 1

PostPosted: Fri Feb 12, 2010 10:39 am    Post subject: easier with Launchy Reply with quote

To do the same, I combined Firefox, XDebug, Platypus, GreaseMonkey, Launchy and Gedit (same syntax as NetBeans: filename:xx)

My GM script extracts a nodeset of TD nodes containing "( ! )" indicating* an error in Xdebug, and for each node transform filename and line number to a link in the form "file://path/filename:xx"

I declared Gedit as browser (via launchy.xml), and a RightClick/ContextualMenu/Launchy/Gedit on the link created by GM do the trick

I preferred this solution over recompiling Xdebug for creating the link

I used Platypus to create a skeleton script and then adapted it :

function do_platypus_script() {
var nodesSnapshot = document.evaluate(
‘//th[contains(.,\'( ! )\')]‘,
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);

for ( var i=0 ; i < nodesSnapshot.snapshotLength; i++ )
{
do_modify_html_it(
window.document,
nodesSnapshot.snapshotItem(i),
/in (.*) on line (.*)/,
‘in $1:$2‘,
null
);
};}
// Ends do_platypus_script

* same principle w/ php errors: have a look @php source code, printf(" … %s … %s …, filename, linenumber "
Back to top
zirawan



Joined: 19 Sep 2010
Posts: 3

PostPosted: Sun Sep 19, 2010 3:47 am    Post subject: Reply with quote

On Windows you could use the following mechanism:

1. In your php.ini (or .htaccess) set option xdebug.file_link_format to value "netbeans://%f?%l"

2. Open Firefox configuration (type about:config in address bar) and create new item of type boolean named network.protocol-handler.expose.netbeans and set its value to false

3. Create bat-file containing following script (don't forget to set valid paths for PHP CLI and NetBeans):

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
set php="full_path_to_php.exe"
set NetBeans="full_path_to_netbeans.exe"
IF NOT "%~1"=="" FOR /F "tokens=1,2* delims=^?" %%A IN ('%php% -r "echo substr(urldecode('%~1'),11);"') DO set file=%%A & set line=%%B
%NetBeans% --nosplash --console suppress --open "!file!":!line!


4. Once the error link clicked for the first time Firefox will ask for the handler for "netbeans://" protocol. Point it to created bat-file

Update (thanx to capnhud): Since Firefox not let you to choose bat-files, enter full file path manually.

5 ...

6. PROFIT!!! Smile


Last edited by zirawan on Thu Feb 17, 2011 6:49 pm; edited 1 time in total
Back to top
capnhud



Joined: 09 Aug 2010
Posts: 8

PostPosted: Wed Feb 16, 2011 7:09 pm    Post subject: Reply with quote

zirawan wrote:
On Windows you could use the following mechanism:

1. In your php.ini (or .htaccess) set option xdebug.file_link_format to value "netbeans://%f?%l"

2. Open Firefox configuration (type about:config in address bar) and create new item of type boolean named network.protocol-handler.expose.netbeans and set its value to false

3. Create bat-file containing following script (don't forget to set valid paths for PHP CLI and NetBeans):

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
set php="full_path_to_php.exe"
set NetBeans="full_path_to_netbeans.exe"
IF NOT "%~1"=="" FOR /F "tokens=1,2* delims=^?" %%A IN ('%php% -r "echo substr(urldecode('%~1'),11);"') DO set file=%%A & set line=%%B
%NetBeans% --nosplash --console suppress --open "!file!":!line!


4. Once the error link clicked for the first time Firefox will ask for the handler for "netbeans://" protocol. Point it to created bat-file.

5 ...

6. PROFIT!!! Smile



This does not let you choose the .bat file it keeps looking for an application
Back to top
zirawan



Joined: 19 Sep 2010
Posts: 3

PostPosted: Thu Feb 17, 2011 6:45 pm    Post subject: Reply with quote

capnhud wrote:

This does not let you choose the .bat file it keeps looking for an application


Just manually enter full path of bat-file into "File name" field in that "Another Application..." dialog.
Back to top
rowanreid



Joined: 15 Dec 2008
Posts: 2

PostPosted: Sun Jul 10, 2011 10:14 pm    Post subject: Reviving this Reply with quote

I found the above solution from zirawan almost worked for me, but I had to make some changes. (I was getting an error when it was trying to run the php command)

First, I adjusted the xdebug.file_link_format which he had as:

netbeans://%f?%l

TO

netbeans://%f:%l

Then, I replaced the batch file code with this:

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
set NetBeans="full_path_to_netbeans.exe"
set parameter=%~1
%NetBeans% --nosplash --console suppress --open %parameter:~11%


Basically, I took out the need for access to the php.exe by using a batch command to perform the substring. Also, since I use a : instead of a ? to delimit the filename and the line number I can send it straight to netbeans without having to parse.
Back to top
zirawan



Joined: 19 Sep 2010
Posts: 3

PostPosted: Tue Jul 26, 2011 11:09 am    Post subject: Re: Reviving this Reply with quote

rowanreid wrote:
Basically, I took out the need for access to the php.exe by using a batch command to perform the substring. Also, since I use a : instead of a ? to delimit the filename and the line number I can send it straight to netbeans without having to parse.


Quite nice improvement, man! Works just fine for me. Thanks a lot.
Back to top
ulyssey



Joined: 12 Mar 2011
Posts: 5

PostPosted: Wed Nov 23, 2011 9:09 pm    Post subject: handling space in url Reply with quote

Thanks a lot for the scripts, they are really useful.
Because of spaces in my url it did not work. After a look on internet to find how to make it works I modify a bit the script of rowanreid as follow:

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
set NetBeans="C:\Archivos de programa\NetBeans 7.1 Beta\bin\netbeans.exe"
set parameter=%~1
set "parameter=!parameter:%%20= !"
set "parameter=!parameter://=//"!"
set "parameter=!parameter:.php:=.php":!"
%NetBeans% --nosplash --console suppress --open %parameter:~11%


I suppose there is a better way to do it but at least it works.
Back to top
daajack



Joined: 21 Jan 2012
Posts: 2

PostPosted: Sat Jan 21, 2012 1:34 pm    Post subject: Re: Reviving this Reply with quote

rowanreid wrote:

Code:
@echo off
setlocal enableextensions enabledelayedexpansion
set NetBeans="full_path_to_netbeans.exe"
set parameter=%~1
%NetBeans% --nosplash --console suppress --open %parameter:~11%



I updated the script, with a call to a command line utility : nircmd, to bring netbeans window to front.

A added this line at the end of the script :

Code:
path_to_exe/nircmd win activate process netbeans.exe


Thanks to all.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> PHP Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo