enumag enumag - 1 year ago 115
PHP Question

How to detect php xdebug in shell script

Basically if php has xdebug installed I want to run tests with code coverage enabled. Otherwise just run the tests without code coverage. Something like this:

if [[ <detect xdebug> ]]; then coverage="--coverage-xml"; fi
vendor/bin/codecept run $coverage

It's easy to know if xdebug enabled using

php -v | grep Xdebug

If this command returns something xdebug is enabled, otherwise it's unavailable.

I just don't know how to use it in the if.

Answer Source
if php -v | grep -q 'Xdebug'; then
  echo "Xdebug installed"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download