安裝vendor文件夾中的依賴
一般我從Github或者國內的碼雲上克隆項目下來后,第一件事就是執行composer install命令。install命令從當前目錄讀取composer.json文件,處理了依賴關系,並把其安裝到vendor目錄下。
如果當前目錄下存在composer.lock文件,它會從此文件讀取依賴版本,而不是根據composer.json文件去獲取依賴。這確保了該庫的每個使用者都能得到相同的依賴版本。
如果沒有composer.lock文件,composer將在處理完依賴關系后創建它。
找到有composer.json的目錄,使用命令
composer install
發現安裝失敗
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 70 installs, 0 updates, 0 removals
- Installing doctrine/annotations (v1.4.0): Downloading (failed)
Downloading (failed)
Downloading (failed) Failed to download doctrine/annotations from dist: The "https://files.phpcomposer.com/files/doctrine/annotations/54cacc9b81758b14e3ce750f205a393d52339e97.zip" file could not be downloaded: failed to open stream: ▒▒▒▒Ŀ▒▒▒▒▒▒▒▒▒▒▒ܾ▒▒▒▒▒▒▒▒ӡ▒
Now trying to download from source
- Installing doctrine/annotations (v1.4.0): Cloning 54cacc9b81 from cache
shiyimin@SC-201809211007 MINGW64 /e/localhost/frankiez-shiheng-develop/shiheng
$ composer require doctrine/dbal
Using version ^2.9 for doctrine/dbal
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
使用命令,設置忽略版本匹配
composer update --ignore-platform-reqs
安裝成功
參考 https://www.php.cn/tool/composer/432778.html