Skip to content

Instantly share code, notes, and snippets.

@grimzy
Last active November 23, 2016 05:35
Show Gist options
  • Save grimzy/a8f76cca9dd545ca87285d67b859a2c4 to your computer and use it in GitHub Desktop.
Save grimzy/a8f76cca9dd545ca87285d67b859a2c4 to your computer and use it in GitHub Desktop.
Composer without xdebug
#!/usr/bin/env bash
# Adapted from From http://stackoverflow.com/a/36723363/2657607
function php_no_xdebug {
local temporaryPath="$(mktemp -t php.XXXX).ini"
# Using awk to ensure that files ending without newlines do not lead to configuration error
php -i | grep "\.ini" | grep -o -e '\(/[a-z0-9._-]\+\)\+\.ini' | grep -v xdebug | xargs awk 'FNR==1{print ""}1' > "$temporaryPath"
php -n -c "$temporaryPath" "$@"
rm -f "$temporaryPath"
}
composer_bin=$(whereis composer | awk '{print $(NF-1)}')
php_no_xdebug "$composer_bin" $@
# On MacOS with composer installed using brew, comment previous line
# Install jq by executing `brew install jq` and uncomment following line.
# php_no_xdebug /usr/local/Cellar/composer/`brew info --json=v1 composer | jq -r '.[0].installed[0].version'`/libexec/composer.phar $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment