I’ve spent far more time trying to make this work than I care to admit. The mistake I’ve made in the past is to try and do this in a batch file, I’ve now done it in bash (which I have anyway since I installed Git and asked for unix-tools to be globally available).
xDebug lets you turn file names into click able links, which can in turn be used to launch your text editor in the right place.
- bash & sed – These come when you install Git and ask for the Unix tools to be globally available
- Programmers Notepad – naturally. Though this is easy enough to tweak to any editor.
- Firefox and xDebug
Step 1 – Create the SH file
Put this text into a file called “EditWithPnotepad.sh” and save it somewhere sensible. You may need to tweak the last line, especially if you want to use this for an editor other than PNotepad.
#!/bin/bash uo=$1 protocol=$(echo $uo | sed 's/\([a-z]*\):\/\/\(.*\):\([0-9]*\)\//\1/'); file=$(echo $uo | sed 's/\([a-z]*\):\/\/\(.*\):\([0-9]*\)\//\2/'); line=$(echo $uo | sed 's/\([A-z]*\):\/\/\(.*\):\([0-9]*\)\//\3/'); "C:\Program Files (x86)\Programmer's Notepad\pn.exe" --line $line "$file" &
Step 2 – Register the protocol
Open regedit and create the following keys – we’ll set the values after. Do this by right clicking on the parent (HKEY_CLASSES_ROOT, then pontepad etc) and clicking on New > Key.
[HKEY_CLASSES_ROOT\pnotepad] [HKEY_CLASSES_ROOT\pnotepad\shell] [HKEY_CLASSES_ROOT\pnotepad\shell\open] [HKEY_CLASSES_ROOT\pnotepad\shell\open\command]
Click on pnotepad and the double click on (default) to change it. Set it to “URL: PNotepad Protocol”.
Under that same (default) key right click in the blank space and click on New > Key and name it “URL Protocol”. It needs no value.
Now click on Command and set its (default) to your own version of the following, be careful not to mess up the quotes or spaces.
"C:\Program Files (x86)\Git\bin\sh.exe" "D:\Path\To\Your\EditWithPnotepad.sh" "%1"
Step 3 – Tell xDebug how to format URLs
Open up your php.ini and add or edit this line, then restart PHP/Apache as required.
Step 4 – Test
That should be it, make some code code throw an error and try clicking the link.
Any touble, or updates let me know!