且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用composer下载依赖关系时删除文件

更新时间:2023-11-16 23:31:34

您可以添加

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.