1 Star 0 Fork 38

虎皮猫大人/PHP 环境一把梭安装工具集

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
composer.sh 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
宇润 提交于 2020-02-20 19:42 . 增加 Composer 安装检测
#!/bin/bash
read -p "是否下载安装 Composer?(y/n):" install
echo -e "\033[32m请选择中国镜像源:\033[0m"
echo -e "\033[32m1-阿里云\033[0m"
echo -e "\033[32m2-腾讯云\033[0m"
echo -e "\033[32m3-华为云\033[0m"
echo -e "\033[32m4-cnpkg\033[0m"
echo -e "\033[32m其它-不使用镜像\033[0m"
read -p "请选择:" chineseCDN
read -p "是否安装 Composer 多线程加速下载包?(y/n):" speedUp
if [[ $install = "y" ]] || [[ $install = "" ]]; then
# 删除已存在文件
if [[ -f composer.phar ]]; then
rm composer.phar
fi
# 下载
downloadUrl="https://getcomposer.org/composer-stable.phar"
if (type wget >/dev/null 2>&1); then
echo -e "\033[32m正在使用 wget 下载 Composer...\033[0m"
wget -O composer.phar $downloadUrl
elif (type curl >/dev/null 2>&1); then
echo -e "\033[32m正在使用 curl 下载 Composer...\033[0m"
curl -o composer.phar $downloadUrl
else
echo -e "\033[31mError: 没有找到 wget / curl\033[0m"
exit 1
fi
echo -e "\033[32m安装中...\033[0m"
# 增加权限
chmod +x composer.phar
# 移动到可执行目录
mv -f composer.phar /usr/local/bin/composer
# 兼容部分系统 /usr/local/bin 没在 PATH
if !(composer -V >/dev/null 2>&1); then
mv -f /usr/local/bin/composer /usr/bin/composer
fi
fi
# 测试
echo -e "\033[32m测试:\033[0m"
if !(composer -V); then
echo -e "\033[31mError: Composer 安装失败\033[0m"
exit 1
fi
# 镜像设置
if [[ $chineseCDN = "1" ]]; then
echo -e "\033[32mComposer 阿里云镜像设置:\033[0m"
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
elif [[ $chineseCDN = "2" ]]; then
echo -e "\033[32mComposer 腾讯云镜像设置:\033[0m"
composer config -g repo.packagist composer https://mirrors.cloud.tencent.com/composer/
elif [[ $chineseCDN = "3" ]]; then
echo -e "\033[32mComposer 华为云镜像设置:\033[0m"
composer config -g repo.packagist composer https://mirrors.huaweicloud.com/repository/php/
elif [[ $chineseCDN = "4" ]]; then
echo -e "\033[32mComposer cnpkg镜像设置:\033[0m"
composer config -g repo.packagist composer https://php.cnpkg.org
fi
# Composer 多线程加速下载包
if [[ $speedUp = "y" ]] || [[ $speedUp = "" ]]; then
echo -e "\033[32m安装 Composer 多线程加速下载包:\033[0m"
composer global require hirak/prestissimo
fi
echo -e "\033[32m安装成功!\033[0m"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/wilbur-yu/php-env.git
git@gitee.com:wilbur-yu/php-env.git
wilbur-yu
php-env
PHP 环境一把梭安装工具集
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385