使用composer下载依赖关系时删除文件 [英] Remove files when downloading a dependency with composer
问题描述
我确定我曾经在某个地方读过它,但是我找不到它了。
基本上我想做的是指定一些排除标准在我的composer.json文件中的某个库,所以,当用作一个项目的依赖项,导入项目不会获取测试文件,.git文件夹,READ.md文件和所有的东西(完全没用只需要一个库作为依赖,而不是用于开发)。所以基本上我试图减轻我的libs当他们作为依赖下载。
您可以添加
code> .gitattributes 文件到您的项目根目录,看起来像这样: 测试export-ignore
READ.md export-ignore
当有人安装您的依赖关系时,此文件将从分发邮件中排除。
您的lib可以通过composer下载为zip格式的一些先决条件
- 您需要有一个稳定的标记版本。
dev-master
将始终由作曲家克隆。 - 如果用户安装
composer install --prefer
在所有其他情况下,composer会下载zip文件并且 .gitattributes
中的所有文件将被排除。
希望这有助于。
I am sure I once read it somewhere but I cannot find it anymore anywhere, DAMN!
So basically what I am trying to do is to specify some exclusion criteria in my composer.json file for a certain library of mine so that, when used as a dependency of a project, the importing project does not get test files, .git folders, READ.md files and all that stuff (totally useless when you only want a library as a dependency and not for development).
So basically I am trying to lighten up my libs when they are downloaded as dependencies. Anyone on that?
Ta
You can add a .gitattributes
file to your project root, looking something like this:
/Tests export-ignore
READ.md export-ignore
When someone installs your dependency this files will be excluded from the distribution zip. There are some prerequisites for your lib to be downloaded as a zip by composer
- You need to have a stable tagged version.
dev-master
will always be cloned by composer. - If the user installs with
composer install --prefer-source
composer will also clone from your git repo.
In all other cases composer will download the zip and all the files in .gitattributes
will be excluded from it.
Hope this helps.
这篇关于使用composer下载依赖关系时删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!