crrad
crrad

Reputation: 186

Check if xdebug is running

I have some AJAX queries executing repeatedly. So, if xdebug is running, I don't want to execute any of them.

Question is: how to determine in PHP code, whether xdebug is currently running?

Upvotes: 3

Views: 4800

Answers (3)

Glorious Kale
Glorious Kale

Reputation: 1313

Run:

php -v

inside your command line.

If xDebug is running, you should get an extended string, something like:

with Xdebug v2.5.1, Copyright (c) 2002-2018, by Derrick Rethans

Upvotes: 0

Bence Szalai
Bence Szalai

Reputation: 922

From Xdebug v2.6 You can use the xdebug_is_debugger_active() function: "Returns whether a debugging session is active" (from https://xdebug.org/docs/all_functions )

If you are not sure that Xdebug is even installed or enabled, check that first before calling this function or you can always use function_exists( 'xdebug_is_debugger_active' ) && xdebug_is_debugger_active() as a condition.

Upvotes: 6

Sven
Sven

Reputation: 70893

I'd try to ask extension_loaded about xdebug.

Upvotes: 1

Related Questions