安装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