作曲家中 require 和 install 与 create-project 之间的区别

Difference between require and install vs create-project in composer(作曲家中 require 和 install 与 create-project 之间的区别)
本文介绍了作曲家中 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-projectclone 依赖项,即将依赖项用作新项目的模板.看看 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

这篇关于作曲家中 require 和 install 与 create-project 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)