Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support editor link on QueryCollector/ExceptionsCollector #1426

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

erikn69
Copy link
Contributor

@erikn69 erikn69 commented Jul 13, 2023

This PR allow us to easy open files on editor from queries widget

image

I also avoid duplicating the same code again, now it uses build-in methods

protected $editors = [
'sublime' => 'subl://open?url=file://%file&line=%line',
'textmate' => 'txmt://open?url=file://%file&line=%line',
'emacs' => 'emacs://open?url=file://%file&line=%line',
'macvim' => 'mvim://open/?url=file://%file&line=%line',
'phpstorm' => 'phpstorm://open?file=%file&line=%line',
'idea' => 'idea://open?file=%file&line=%line',
'vscode' => 'vscode://file/%file:%line',
'vscode-insiders' => 'vscode-insiders://file/%file:%line',
'vscode-remote' => 'vscode://vscode-remote/%file:%line',
'vscode-insiders-remote' => 'vscode-insiders://vscode-remote/%file:%line',
'vscodium' => 'vscodium://file/%file:%line',
'nova' => 'nova://core/open/file?filename=%file&line=%line',
'xdebug' => 'xdebug://%file@%line',
'atom' => 'atom://core/open/file?filename=%file&line=%line',
'espresso' => 'x-espresso://open?filepath=%file&lines=%line',
'netbeans' => 'netbeans://open/?f=%file:%line',
];

protected $editors = [
'sublime' => 'subl://open?url=file://%file&line=%line',
'textmate' => 'txmt://open?url=file://%file&line=%line',
'emacs' => 'emacs://open?url=file://%file&line=%line',
'macvim' => 'mvim://open/?url=file://%file&line=%line',
'phpstorm' => 'phpstorm://open?file=%file&line=%line',
'idea' => 'idea://open?file=%file&line=%line',
'vscode' => 'vscode://file/%file:%line',
'vscode-insiders' => 'vscode-insiders://file/%file:%line',
'vscode-remote' => 'vscode://vscode-remote/%file:%line',
'vscode-insiders-remote' => 'vscode-insiders://vscode-remote/%file:%line',
'vscodium' => 'vscodium://file/%file:%line',
'nova' => 'nova://core/open/file?filename=%file&line=%line',
'xdebug' => 'xdebug://%file@%line',
'atom' => 'atom://core/open/file?filename=%file&line=%line',
'espresso' => 'x-espresso://open?filepath=%file&lines=%line',
'netbeans' => 'netbeans://open/?f=%file:%line',
];

Also getEditorHref was removed, now it uses build-in methods

Related #1258, #1359,

@erikn69 erikn69 force-pushed the patch-4 branch 5 times, most recently from 9a16a26 to 2d9b7b8 Compare July 17, 2023 13:51
@erikn69 erikn69 force-pushed the patch-4 branch 4 times, most recently from 177ce15 to 618c9ae Compare July 17, 2023 21:47
@erikn69 erikn69 changed the title Support editor link on QueryCollector Support editor link on QueryCollector/ExceptionsCollector Jul 17, 2023
@erikn69
Copy link
Contributor Author

erikn69 commented Jul 17, 2023

hi @barryvdh, ready for review,
getEditorHref, replaceSitesPath, were removed in favor of the default getXdebugLink method which performs the same process(also it is supported on default js widgets)

Now,
editor can be assigned to any collector with default build-in method setEditorLinkTemplate
normalizeFilename replaced with default build-in method normalizeFilePath
debugbar.remote_sites_path can be assigned to any collector with default method setXdebugReplacements
debugbar.remote_sites_path support one or multiple paths(comma separated)

@erikn69 erikn69 force-pushed the patch-4 branch 2 times, most recently from dccf539 to b8e39a9 Compare July 18, 2023 19:45
@erikn69 erikn69 force-pushed the patch-4 branch 8 times, most recently from 719c3f9 to 0327acc Compare September 22, 2023 15:29
@barryvdh barryvdh merged commit 65887ee into barryvdh:master Feb 9, 2024
13 checks passed
@barryvdh
Copy link
Owner

barryvdh commented Feb 9, 2024

Maybe this is a silly question, but am I supposed to configure something before this works?
I'm using Laravel Herd, but the editor links all point to /app/, /resources or /vendor. Do I need to add the base_path somewhere? According to the config it should work for local development?

@erikn69
Copy link
Contributor Author

erikn69 commented Feb 9, 2024

Hi, on config, local_sites_path, remote_sites_path existed, I delegated them to the main package(xdebuglink)

private function getRemoteServerReplacements()
{
$localPath = $this->app['config']->get('debugbar.local_sites_path', '');
$remotePaths = array_filter(explode(',', $this->app['config']->get('debugbar.remote_sites_path', ''))) ?: [base_path()];
return array_fill_keys($remotePaths, $localPath);

@barryvdh
Copy link
Owner

barryvdh commented Feb 9, 2024

Yeah but with the default config, it redirects to the project file link, not the existing one (eg /User/Barry/etc)
image

@barryvdh
Copy link
Owner

barryvdh commented Feb 9, 2024

The path in the view is correct, but the link should be the real path, right?

@barryvdh
Copy link
Owner

barryvdh commented Feb 9, 2024

Or did I merge it incorrectly? (Had some conflicts)

@erikn69
Copy link
Contributor Author

erikn69 commented Feb 9, 2024

Queries
image

Views
image


config/debugbar.php

  ///
  'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', ''),
  ///

.env

DEBUGBAR_LOCAL_SITES_PATH=C:\laravel\ssw

@barryvdh local_sites_path already exists before my changes

@barryvdh
Copy link
Owner

barryvdh commented Feb 9, 2024

But wouldn't it make more sense that value is the base_path() by default already?

@erikn69
Copy link
Contributor Author

erikn69 commented Feb 9, 2024

yes, it would

config/debugbar.php

'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', base_path()),

but that code was already like that, so I didn't modify it

@barryvdh
Copy link
Owner

Yes fixed the config in #1506 and showed just the filename to shorten a bit in #1505
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants