Skip to content

Instantly share code, notes, and snippets.

@Maff-
Last active August 29, 2015 14:23
Show Gist options
  • Save Maff-/054bf786b4c5a8f92614 to your computer and use it in GitHub Desktop.
Save Maff-/054bf786b4c5a8f92614 to your computer and use it in GitHub Desktop.
PhpStormProtocol
# [...] #
framework:
# Uncomment the 'ide' option to turn all of the file paths in an exception
# page into clickable links that open the given file using your favorite IDE.
# Supported values are 'textmate', 'macvim', 'emacs' and 'sublime' shortcuts
# and any custom configuration string, such as: "phpstorm://open?file=%%f&line=%%l"
# See http://symfony.com/doc/current/reference/configuration/framework.html#ide
ide: "pstorm://open?file=%%f&line=%%l"
# [...] #
REGEDIT4
[HKEY_CLASSES_ROOT\pstorm]
@="URL:pstorm Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\pstorm\shell\open\command]
@="wscript \"C:\\Tools\\PhpStormProtocol\\run_editor.js\" \"%1\""
//Andere mogelijkheid:
// url-handler command :
// wscript "C:\Tools\PhpStormProtocol\call_api_curl.js" %0
// php.ini:
// xdebug.file_link_format = "curl://http://localhost:63342/api/file/%f:%l"
//script:
(function() {
if (WScript.Arguments.Length != 1) {
WScript.Quit(1);
}
var url = WScript.Arguments(0).replace(/^curl:\/\//, '');
var shell = new ActiveXObject('WScript.Shell');
var command = '"C:\\Program Files (x86)\\Gow\\bin\\curl.EXE" ' + url + ' --silent --fail';
shell.Run(command, 0, false);
})();
var settings = {
// Set to 'true' (without quotes) if run on Windows 64bit. Set to 'false' (without quotes) otherwise.
x64: true,
// Set to folder name, where PhpStorm was installed to (e.g. 'PhpStorm')
folder_name: 'PhpStorm 141.582',
// Set to window title (only text after dash sign), that you see, when switching to running PhpStorm instance
window_title: 'PhpStorm PS-141.1000'
};
// don't change anything below this line, unless you know what you're doing
var url = WScript.Arguments(0),
match = /^pstorm:\/\/open\/\?file=(.+?)&line=(\d+)$/.exec(url),
project = '',
editor = '"C:\\' + (settings.x64 ? 'Program Files (x86)' : 'Program Files') + '\\JetBrains\\' + settings.folder_name + '\\bin\\PhpStorm.exe"';
if (match) {
var shell = new ActiveXObject('WScript.Shell'),
file_system = new ActiveXObject('Scripting.FileSystemObject'),
file = decodeURIComponent(match[1]).replace(/\+/g, ' '),
search_path = file.replace(/\//g, '\\');
while (search_path.lastIndexOf('\\') != -1) {
search_path = search_path.substring(0, search_path.lastIndexOf('\\'));
if(file_system.FileExists(search_path+'\\.idea\\.name')) {
project = search_path;
break;
}
}
if (project != '') {
editor += ' "%project%"';
}
editor += ' --line %line% "%file%"';
var command = editor.replace(/%line%/g, match[2])
.replace(/%file%/g, file)
.replace(/%project%/g, project)
.replace(/\//g, '\\');
shell.Exec(command);
shell.AppActivate(settings.window_title);
} else {
WScript.Echo('Whooops; given url "'+url+'" was not matched!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment