The standard package name format for a composer package is 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:
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
)
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
)
Is there a way to achieve these 2 points?
You can achieve (1) by using git subtree split. Using this method, you split seperate directories of the main repository into a new repository and push it to 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.).
(2) is not supported. You can use something like my_vendor/third-bundle
instead of 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).
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")
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. Also notice that require-dev
is being resolved only in 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"
Yes. In repositories
, provide vcs
or package
repository and make it resolve myVendorName/bundles/bundle3
. url
in vcs
may refer to local git repo. There's no simple way to alias "myVendorName/bundle3" as "myVendorName/bundles/bundle3", which makes the idea unpractical.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.