my-env/install/composer

42 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/bash
##makedesc: Install composer (latest)
2024-07-31 15:23:55 +00:00
source `dirname $0`/../helpers || exit 255
2022-01-09 08:56:25 +00:00
2022-07-12 15:20:11 +00:00
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
2024-07-31 15:23:55 +00:00
title
2024-07-31 15:23:55 +00:00
require php
2022-07-04 15:24:27 +00:00
if installed "composer"; then
2024-07-31 15:23:55 +00:00
warn "WARNING: Removing current composer to install its actual version"
2022-07-04 15:24:27 +00:00
sudo apt remove -y --autoremove composer
2024-07-31 15:23:55 +00:00
sudo rm -f \
"$HOME/.local/bin/composer" \
/bin/composer \
/usr/bin/composer \
/usr/local/bin/composer \
/usr/src/composer \
"$HOME/.local/bin/composer"
fi
2024-07-31 15:23:55 +00:00
mkdir -p "$HOME/install" "$HOME/.local/bin"
download "https://getcomposer.org/installer" "$HOME/install/composer-setup.php" && \
php "$HOME/install/composer-setup.php" --install-dir="$HOME/.local/bin/composer"
[ $? = 0 ] && {
COMPOSER_GLOBAL_HOME="$($HOME/.local/bin/composer config -g home)"
NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
cat "$HOME/.profile" | grep -qoh "$NEWPATH" || {
$NEWPATH
echo "$NEWPATH" >> "$HOME/.profile"
}
echo
success "composer installed!"
composer --version
echo
2022-12-11 06:48:30 +00:00
}
2024-07-31 15:23:55 +00:00
source "$HOME/.profile"