简体   繁体   English

嵌套目录的作曲家供应商名称格式

[英]composer vendor name format for nested directory

The standard package name format for a composer package is vendor/pkName . 作曲家软件包的标准软件包名称格式为vendor/pkName I've this following directory structure: 我有以下目录结构:

 - myVendorName

    - extensions
      - yii2
        -Ext1
        -Ext2 and so on

    - bundles
      - bundle1
      - bundle2
      - bundle3 and so on

    - toolkit
     - forlder1
     - folder2 and so on

This is the organization that I gave in my harddisk, but the real projects are like: 这是我在硬盘中提供的组织,但是实际的项目如下:

  - myVendorName/extensions/yii2/ext1
  - myVendorName/extensions/yii2/ext2
  - myVendorName/bundles/bundle1
  - myVendorName/bundles/bundle2
  - myVendorName/bundles/bundle3
  - myVendorName/toolkit

My questions about this: 我对此的疑问:

  1. It's possible to store all in one git repository and require with composer only the needed subpackages (for example: require only myVendorName/toolkit and myVendorName/bundles/bundle3 ) 可以将所有内容存储在一个git存储库中,并通过composer仅要求所需的子包(例如:仅要求myVendorName/toolkitmyVendorName/bundles/bundle3

  2. It's possible to maintain the extended name format with composer (so in composer.json require section, require for myVendorName/bundles/bundle3 instead of myVendorName/bundle3 ) 可以使用composer维护扩展名称格式(因此在composer.json require部分中,需要myVendorName/bundles/bundle3而不是myVendorName/bundle3

Is there a way to achieve these 2 points? 有没有办法实现这两点?

You can achieve (1) by using git subtree split. 您可以通过使用git子树拆分来实现(1)。 Using this method, you split seperate directories of the main repository into a new repository and push it to github. 使用此方法,您可以将主存储库的单独目录拆分为一个新存储库,并将其推送到github。 This way, all packages still have their own repository, but you only have to maintain one repository (lots of big projects use this, like Symfony, Laravel, etc.). 这样,所有软件包仍然具有自己的存储库,但是您只需要维护一个存储库(许多大型项目都使用此存储库,例如Symfony,Laravel等)。

(2) is not supported. (2)不支持。 You can use something like my_vendor/third-bundle instead of my_vendor/bundles/third . 您可以使用诸如my_vendor/third-bundle类的东西来代替my_vendor/bundles/third The directory isn't important anyways, as Composer will just perfectly autoload all classes inside the packages (if they have the correct autoloading config). 该目录无论如何都不重要,因为Composer会完美地自动加载包中的所有类(如果它们具有正确的自动加载配置)。

It's possible to store all in one git repository and require with composer only the needed subpackages (for example: require only "myVendorName/toolkit" and "myVendorName/bundles/bundle3") 可以将所有内容存储在一个git存储库中,并通过composer仅要求所需的子包(例如:仅要求“ myVendorName / toolkit”和“ myVendorName / bundles / bundle3”)

Yes. 是。 If you have the same components in different projects that may require specific set of dependencies, consider making them a reusable package instead of an empty package with composer.json. 如果您在不同项目中具有相同的组件,可能需要特定的依赖关系集,请考虑使它们成为可重用的程序包,而不是使用composer.json的空程序包。 Also notice that require-dev is being resolved only in root package . 还要注意, require-dev 仅在root package中得到了解决。

It's possible to maintain the extended name format with composer (so in composer.json require section, require for "myVendorName/bundles/bundle3" instead of "myVendorName/bundle3" 可以使用composer维护扩展名称格式(因此,在composer.json require部分中,需要使用“ myVendorName / bundles / bundle3”而不是“ myVendorName / bundle3”

Yes. 是。 In repositories , provide vcs or package repository and make it resolve myVendorName/bundles/bundle3 . repositories ,提供vcspackage存储库,并使其解析为myVendorName/bundles/bundle3 url in vcs may refer to local git repo. vcs url可以引用本地git repo。 There's no simple way to alias "myVendorName/bundle3" as "myVendorName/bundles/bundle3", which makes the idea unpractical. 没有简单的方法将“ myVendorName / bundle3”别名为“ myVendorName / bundles / bundle3”,这使该想法不切实际。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM