Symfony2 Checks For Composer and Database

A friend of mine @markbadolato got me into using this git post-checkout hook:
update: he also made a blog post with more explanations.

# Put this file at: .git/hooks/post-checkout
# and make it executable
# You can install it system wide too, see
if [[ -f composer.lock ]]; then
    DIFF=`git diff --shortstat $PREV_COMMIT..$POST_COMMIT composer.lock`
    if [[ $DIFF != "" ]]; then
        echo -e "$REDCOLOR composer.lock has changed. You must run composer install$NOCOLOR"
if [[ -f app/console ]]; then
    php app/console doctrine:schema:update --dump-sql

Mind you need to do it as a post-checkout hook.

I added the doctrine part so that it also tells you if you need to run migrations or update the schema.

All credits to its author. I only added the last part. And I adapted it from @markbadolato polished version.

Enjoy and visit us also at the shop if you want to thank for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *