windows环境下 composer 的安装与使用

情到浓时终转凉″ 提交于 2020-08-14 20:54:48

1、下载稳定版本 composer.phar 1.10.8 至 php 安装目录(即与 php.ini 同级)

2、在 composer.phar 同目录下 新建 composer.bat 文件,用记事本打开并输入

@php "%~dp0composer.phar" %*

3、配置 composer  !!! 由于安装了 php5.6 以及 php7.3 ,须指定 php.exe,以下操作皆在 php7.3 下运行  !!!

# 查看 全局配置
./php.exe ./composer.phar config -g -l

# 重置 源
./php.exe ./composer.phar config -g --unset repositories.packagist

# 设置 阿里云源
./php.exe ./composer.phar config -g repositories.packagist composer https://mirrors.aliyun.com/composer/

# 禁用 https 连接
./php.exe ./composer.phar config -g secure-http false

# 运行 诊断命令
./php.exe ./composer.phar diagnose

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: OK
Composer version: 1.10.8
PHP version: 7.3.11
PHP binary path: E:\php7.3\php.exe
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019

#配置 pubkey,按提示打开页面并输入两次 pubkey 
./php.exe ./composer.phar self-update --update-keys

# 再次运行诊断命令
./php.exe ./composer.phar diagnose

Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 1.10.8
PHP version: 7.3.11
PHP binary path: E:\php7.3\php.exe
OpenSSL version: OpenSSL 1.1.1d  10 Sep 2019

4、利用 composer 安装 laravel 7

./php.exe ./composer.phar create-project laravel/laravel /e/Apache/htdocs/laravel/

...
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
44 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!