windows環境下 composer 的安裝與使用


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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM