Skip to content

Instantly share code, notes, and snippets.

@fabiocarneiro
Last active August 29, 2015 14:11
Show Gist options
  • Save fabiocarneiro/7912428ced988f8f824e to your computer and use it in GitHub Desktop.
Save fabiocarneiro/7912428ced988f8f824e to your computer and use it in GitHub Desktop.
#!/bin/bash
# thanks http://www.jenssegers.be/blog/46/deploying-websites-with-git-and-composer-
# replace folder
cd "`dirname $0`/../../application/config"
# Check if a composer.json file is present
if [ -f composer.json ]; then
# Detect composer binary
if which composer >/dev/null; then
composer='composer'
elif which composer.phar >/dev/null; then
composer='composer.phar'
else
# Install composer
curl -s http://getcomposer.org/installer | php >/dev/null
composer='php composer.phar'
fi
# Run composer if composer.json is updated
if [ composer.json -nt composer.lock ]; then
# Install or update depending on lock file
echo "Updating Composer packages"
[ ! -f composer.lock ] && $composer install || $composer update
else
# Regenerating autoload files
echo "Composer packages up to date"
$composer dump-autoload
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment