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

Ignore requests to specific endpoints entirely #909

Closed
iandunn opened this issue Jun 21, 2023 · 5 comments · Fixed by #911
Closed

Ignore requests to specific endpoints entirely #909

iandunn opened this issue Jun 21, 2023 · 5 comments · Fixed by #911
Assignees
Labels

Comments

@iandunn
Copy link

iandunn commented Jun 21, 2023

I'd like to completely ignore any request that comes in to a specific file/URL. I've tried using skipFiles and ignore, but it seems like those will still handle the request, but they will skip the file when stepping through the codebase.


PHP version: 8.0.28
Xdebug version: 3.2.0
VS Code extension version: 1.32.1

launch.json:

{
	"name": "Listen for Xdebug",
	"type": "php",
	"request": "launch",
	"port": 9003,

	"skipFiles": [
		"admin-ajax.php",
		"**/admin-ajax.php",
		"${workspaceFolder}/public_html/mu/wp-admin/admin-ajax.php"
	  ],

	  "ignore": [
		"admin-ajax.php",
		"**/admin-ajax.php",
		"${workspaceFolder}/public_html/mu/wp-admin/admin-ajax.php"
	  ],

	  "maxConnections": 1
}

Xdebug php.ini config:

[xdebug]
zend_extension=/opt/homebrew/Cellar/php@8.0/8.0.28/pecl/20200930/xdebug.so

xdebug.mode = debug,develop
xdebug.idekey = iandunn
xdebug.client_host = 127.0.0.1
xdebug.cli_color = 1
xdebug.var_display_max_data = 1024
xdebug.var_display_max_depth = 6
@zobo
Copy link
Contributor

zobo commented Jun 23, 2023

Hi!
skipFiles is for skipping over files when you do a step-in operation. Commonly referred to as "Just My Code", where you typically don't want to step into framework or vendor code.

ignore is very similar but just ignores exceptions/errors inside those files. "I don't care about exceptions inside vendor.".

Now for your request. If I understand, you would like to debug only certain "entrypoints" or better ignore some entrypoints?
There is currently no configuration for this but what you could do is add some PHP code that can help you here.
Although there is no what to disconnect from debugger in code there is a xdebug_connect_to_client function that can trigger a connection to debugger from code.

How you could use this is that you don't initiate a debug session from the browser (do not set the XDEBUG_SESSION cookie) but rather add a call xdebug_connect_to_client(); in such code location that will only trigger on the desired entrypoint.

Let me know if this is clear. And be sure not to commit and deploy to production :)

Maybe you could also abuse the XDEBUG_SESSION_STOP GET parameter, but I have not tried such monstrosity...

Best!

@iandunn
Copy link
Author

iandunn commented Jun 23, 2023

Thanks, that's helpful info. It doesn't seem too convenient, though. I switched over from PHPStorm and it was easy to do this there, so I was looking for something similar.

IMO it'd be a good feature to add, but I totally understand if there isn't a lot of demand for it.

@zobo
Copy link
Contributor

zobo commented Jun 23, 2023

I see. Should not be that hard to implement. Will leave this open and see if I can get to it.

@iandunn
Copy link
Author

iandunn commented Jun 23, 2023

Sounds good, thanks!

@iandunn
Copy link
Author

iandunn commented Jul 26, 2023

This is working for me, thanks!

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