Skip to content

Instantly share code, notes, and snippets.

@bytespider
Created November 30, 2012 15:38
Show Gist options
  • Save bytespider/4176493 to your computer and use it in GitHub Desktop.
Save bytespider/4176493 to your computer and use it in GitHub Desktop.
PHP pre-commit hook
ROOT_DIR=$(git rev-parse --show-toplevel);
PHP="php -l"
for file in $(git diff-index --name-only --diff-filter=ACM --cached HEAD -- | grep -e '\.(php|phtml)$'); do
$OUTPUT = $PHP $file 2>&1
if $OUTPUT | grep 'No syntax errors detected'; then
exit 0
else
echo $OUTPUT
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment