vscode-php-debug icon indicating copy to clipboard operation
vscode-php-debug copied to clipboard

Please add option to launch browser automatically when debug is starting

Open martonx opened this issue 8 years ago • 10 comments

Hi,

PHP Debug extension is great. But please add an option to launch automatically the default browser, not just listening for xdebug.

So this section:

{ "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9000 }

should lanunch not just in the debug console. but in real browser the currently open script.

Thank you very much!

martonx avatar Jan 04 '17 15:01 martonx

In real browser the currently open script? How should the debugger know what URL maps to that script? This ist also not easy to get right cross-platform

felixfbecker avatar Jan 04 '17 16:01 felixfbecker

Is it possible to launch a browser when just listening for XDebug, not running on the currently open script?

skegel13 avatar Apr 30 '17 19:04 skegel13

I assume it would be possible to open a browser with an empty tab.

felixfbecker avatar Apr 30 '17 19:04 felixfbecker

I was thinking may something in the configuration where you can provide a URL for the application with the parameter to start Xdebug. So I could say I want the URL to be http://localhost and then it would open http://localhost?XDEBUG_SESSION_START=vscode in my default browser.

skegel13 avatar Apr 30 '17 20:04 skegel13

Are you aware that you don't need that query parameter?

felixfbecker avatar Apr 30 '17 20:04 felixfbecker

I am using remote Xdebug through Vagrant. If I don't use that parameter, it doesn't seem to listen to anything.

skegel13 avatar Apr 30 '17 20:04 skegel13

So I am trying it out without the parameter and it does appear to be working now. I guess having the URL config is not necessary then.

skegel13 avatar Apr 30 '17 20:04 skegel13

@felixfbecker @skegel13 Has there been a solution for this?

ahmedmrefaat avatar Aug 19 '18 10:08 ahmedmrefaat

There are options for this: In case of Listen, you can use preLaunchTask and reference a task in tasks, like this:

launch.json

    {
      "name": "Listen for Xdebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "preLaunchTask": "BROWSER"
    },

tasks.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"label": "BROWSER",
			"type": "shell",
			"windows": {
				"command": "start http://localhost:1111"
			}
		}
	]
}

This is windows specific, but can probably be adapted for osx and linux.

I'm leaving this open, so I can properly document this.

zobo avatar May 10 '21 08:05 zobo

The other launch.json key is serverReadyAction...

zobo avatar May 10 '21 09:05 zobo