Linux上安装Composer并配置大陆地区软件镜像

     0评论

安装Composer

参考:https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-16-04

# 更新软件源并安装必要的依赖 $ sudo apt-get update $ sudo apt-get install curl php-cli php-mbstring git unzip

下载composer并将其安装到全局:

# 进入工作目录 $ cd ~ # 下载官方的安装脚本并重命名 文件几百K 如果网络问题下载不了,通过其他方式拿到文件并重命名即可 $ curl -sS https://getcomposer.org/installer -o composer-setup.php # 校验文件 这行不要拷贝使用 去https://getcomposer.org/download/看最新版,因为文件更新后,校验码就不一样了 $ php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" # 将composer安装到全局 $ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer # 执行测试 $ composer

以下是运行composer的输出结果:

[email protected]:~# composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version @[email protected] (1.0.0-beta2) 2016-03-27 16:00:34 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 -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. -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 Short information about Composer archive Create an archive of this composer package browse Opens the package's repository URL or homepage in your browser. clear-cache Clears composer's internal package cache. clearcache Clears composer's internal package cache. config Set config options create-project Create 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 Execute a vendored binary/script 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. info Show 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 Show information about licenses of dependencies list Lists commands 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-script Run the scripts defined in composer.json. search Search for packages show Show information about packages status Show a list of locally modified packages suggests Show package suggestions update Updates 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 config -g repo.packagist composer https://packagist.phpcomposer.com

参考资料

-- EOF --

本文最后修改于2年前 (2018-06-19)

差评不太行一般挺好非常不错 (No Ratings Yet)
读取中...
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址