【阿里云镜像】macOS 安装 composer 作者: Chuwen 时间: 2020-11-23 分类: macOS # 下载 > 由于在官网下载 `composer` 比较慢,所以我们可以使用 **阿里云 Composer 全量镜像** 下载 > 但我还是贴出 *官方下载&安装:`curl -sS getcomposer.org/installer | php`* ```shell # 下载 composer.phar curl https://mirrors.aliyun.com/composer/composer.phar -O composer.phar # 检查版本号 php composer.phar -v ``` # 如果需要全局使用 > 可以移动 `composer.phar` 到 `/usr/local/bin/` 路径下 ```shell sudo mv composer.phar /usr/local/bin/composer ``` ## 可能因为权限问题,直接执行 `composer` 会报权限不够 ```log chuwen@WenzhoudeMBP cms.iton.pw % composer -v zsh: permission denied: composer ``` ## 设置下权限即可 ```log sudo chomd -R 755 /usr/local/bin/composer ``` # 测试(输出版本号) > 记得往下,改 `阿里云 Composer 镜像源`,安装项目起飞?️ ```shel chuwen@WenzhoudeMBP cms.iton.pw % composer -v ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.0.7 2020-11-13 17:31:06 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. --no-cache Prevent use of the cache -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: about Shows the short information about Composer. archive Creates an archive of this composer package. browse Opens the package's repository URL or homepage in your browser. cc Clears composer's internal package cache. check-platform-reqs Check that platform requirements are satisfied. clear-cache Clears composer's internal package cache. clearcache Clears composer's internal package cache. config Sets config options. create-project Creates new project from a package into given directory. depends Shows which packages cause the given package to be installed. diagnose Diagnoses the system to identify common errors. dump-autoload Dumps the autoloader. dumpautoload Dumps the autoloader. exec Executes a vendored binary/script. fund Discover how to help fund the maintenance of your dependencies. global Allows running commands in the global composer dir ($COMPOSER_HOME). help Displays help for a command home Opens the package's repository URL or homepage in your browser. i Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json. info Shows information about packages. init Creates a basic composer.json file in current directory. install Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json. licenses Shows information about licenses of dependencies. list Lists commands outdated Shows a list of installed packages that have updates available, including their latest version. prohibits Shows which packages prevent the given package from being installed. remove Removes a package from the require or require-dev. require Adds required packages to your composer.json and installs them. run Runs the scripts defined in composer.json. run-script Runs the scripts defined in composer.json. search Searches for packages. self-update Updates composer.phar to the latest version. selfupdate Updates composer.phar to the latest version. show Shows information about packages. status Shows a list of locally modified packages. suggests Shows package suggestions. u Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file. update Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file. upgrade Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file. validate Validates a composer.json and composer.lock. why Shows which packages cause the given package to be installed. why-not Shows which packages prevent the given package from being installed. ``` # 切换成 阿里云 Composer 镜像源 ## 1. 全局配置(推荐) ```shell composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 取消当前项目配置 composer config --unset repos.packagist ``` ## 2. 仅在当前项目配置 ```shell composer config repo.packagist composer https://mirrors.aliyun.com/composer/ # 取消全局配置 composer config -g --unset repos.packagist ``` 标签: PHP, Composer