laravel 作曲家如何工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31646642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How composer works?
提问by Vishal Patel
I haven't any idea about how composer works and add directory in our folder structure.
我不知道 Composer 如何工作并在我们的文件夹结构中添加目录。
Recently I want to add repository to my laravel installation so for that i have used https://github.com/prettus/l5-repository, this repo and as per its installation steps, the first step is to execute following command :
最近我想将存储库添加到我的 Laravel 安装中,因此我使用了https://github.com/prettus/l5-repository,这个 repo 并根据其安装步骤,第一步是执行以下命令:
composer require prettus/l5-repository
composer require prettus/l5-repository
this command creates prettus directory under vendor so how this works and manage all things?
这个命令会在 vendor 下创建 prettus 目录,那么它是如何工作和管理所有东西的?
My questions are:
我的问题是:
what is the main purpose of composer?
what is best structure for that?
how it will handle depencdency?
what is the
"autoload"
and 'psr-4` and use of both?correct path and structure for namesapcing 'autoload' and 'psr-4'?
作曲家的主要目的是什么?
什么是最好的结构?
它将如何处理依赖?
"autoload"
和“psr-4”是什么以及两者的用途?命名“自动加载”和“psr-4”的正确路径和结构?
回答by Vishal Patel
Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default it will never install anything globally. Thus, it is a dependency manager.
Composer 不像 Yum 或 Apt 那样是一个包管理器。是的,它处理“包”或库,但它在每个项目的基础上管理它们,将它们安装在项目内的目录(例如供应商)中。默认情况下,它永远不会全局安装任何东西。因此,它是一个依赖管理器。
This idea is not new and Composer is strongly inspired by node's npm and ruby's bundler.
这个想法并不新鲜,而且 Composer 受到了 node 的 npm 和 ruby 的打包器的强烈启发。
Suppose:
认为:
a) You have a project that depends on a number of libraries.
a) 您有一个依赖于许多库的项目。
b) Some of those libraries depend on other libraries.
b) 其中一些库依赖于其他库。
Composer:
作曲家:
c) Enables you to declare the libraries you depend on.
c) 使您能够声明您所依赖的库。
d) Finds out which versions of which packages can and need to be installed, and installs them (meaning it downloads them into your project).
d) 找出可以和需要安装哪些软件包的哪些版本,并安装它们(意味着它将它们下载到您的项目中)。
Ref:https://getcomposer.org/doc/00-intro.md#dependency-management
参考:https: //getcomposer.org/doc/00-intro.md#dependency-management