Composer Run Utility BASH Script

I thought I would post up this little snippet of BASH script that I tend to use with projects that use composer.

It combines an install/update mechanism for composer itself and then runs through the composer install process and dumps the optimised autoloader.

Hope you find it useful:

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Checking for Composer"
COMPOSER_CMD=$(which composer)
if [[ "" == "$COMPOSER_CMD" ]]
    echo "Installing Composer"
    curl -sS | php -- --install-dir=bin
    COMPOSER_CMD=$(which composer)
    echo "Updating Composer"
    $COMPOSER_CMD selfupdate
echo "Running Composer"
cd $DIR
$COMPOSER_CMD dumpautoload -o
echo "Done.."

Tags: phpbashcomposer