enumag enumag - 6 months ago 51
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.

if php -v | grep -q 'Xdebug'; then
  echo "Xdebug installed"