作曲家中 require 和 install 与 create-project 之间的区别
我不明白 create-project
在作曲家中是如何工作的.让我们以 Laravel 为例.
I don't get how the create-project
works in composer. Lets take Laravel as example.
我可以使用以下命令安装这个 PHP 框架:
I can install this PHP framework with the following command:
composer create-project laravel/laravel --prefer-dist
此命令为我安装框架,在我的目录的根目录中留下几个文件夹:
This command installs the framework for me leaving me with a few folder in the root of my dir:
- 应用
- 引导
- 公开
- 供应商
加上一些文件.
但是当我简单地使用以下composer命令时:
But when I simply use the following composer command:
composer require laravel/laravel --prefer-dist
composer install
那么这只会安装 vendor
文件夹.composer 不会下载其他文件和文件夹.
Then this only installs the vendor
folder. No other files and folders are downloaded by composer.
怎么会?有什么不同?当我使用 create-project laravel/laravel
命令时,composer 如何知道要获取哪些其他文件以及为什么我在执行 require 时只获取
?vendor
文件夹laravel/laravel
How come? What is so different? How does composer know what other files to get when I use the create-project laravel/laravel
command and why do I only get the vendor
folder when I do require laravel/laravel
?
推荐答案
require
会在 composer.json
文件中添加一个依赖并加载到 vendor
目录,正如您正确注意到的那样.
require
will add a dependency to the composer.json
file and load it into the vendor
directory as you have correctly noticed.
create-project
将clone 依赖项,即将依赖项用作新项目的模板.看看 laravel/laravel
背后的仓库:https://github.com/laravel/laravel
create-project
on the other hand will clone the dependency, i.e. use the dependency as a template for a new project. Take a look at the repository behind laravel/laravel
: https://github.com/laravel/laravel
相关文章