允许opensourced项目的用户将自己的文件添加到他们的副本中 [英] Allow users of an opensourced project to add their own files to their copy

查看:166
本文介绍了允许opensourced项目的用户将自己的文件添加到他们的副本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我创建了一个半流行的开源项目,并且正在寻找其方法用户自定义他们的副本。



基本上我没有经验使用作曲家,并且没有使用git子模块。

  / ROOT 
---- /子目录/
--------- / another.file.php
---- / main.class.php
---- / config.default.php

这对用户来说能够复制 config.default.php 到相同的目录,将它重命名为 config.php (并且这样做会覆盖默认配置值) - 我希望它们能够添加它们自己的文件到 /子目录/ ,这样他们就可以将工具扩展到他们独特的需求。



我的问题是,当拉(在git子模块的情况下)或Composer更新被执行时,那些文件不会被修剪?如果是这样,我怎么才能达到要求,尽可能为最终用户做一些小事:


  1. 一个单一的,可选的,可自由编辑的配置文件

  2. 两个可以包含用户创建文件的目录

  3. 以上更改保留在用户自己的版本控制系统中,并且在新版本

非常感谢您的耐心等待。

解决方案

大多数应用程序框架/ CMS最近做的事情是将这个过程分成两个包:


  • 一个包含大量代码的库包(例如symfony / symfony,laravel / framework),这些包将安装在vendor /

  • 一个bootstrap包中(例如symfony / framework - 标准版,laravel / laravel),其中包含用户可以从中启动的应用程序外壳。这将包含默认配置和composer.json,其中包含库包+require部分中需要的任何其他内容。此引导程序包通常不会通过作曲者更新,因为它会成为用户的应用程序/网站。因此它应该包含尽可能少的代码,并且基本上只是配置。


So I'm creating a semi-popular open source project and am looking for ways for its users to customize their copy.

Basically I've zero experience using Composer and next to none with git submodules. I have this file structure pushed to git:

/ROOT
----/subdirectory/
---------/another.file.php
----/main.class.php
----/config.default.php

It would be ideal for users to be able to copy config.default.php to the same directory, rename it to config.php (and by doing that override the default configuration values) - and I'd like them to be able to add their own files to the /subdirectory/ too, allowing them to extend the tool to their unique requirements.

My question is, don't those files get trimmed when pull (in the case of git submodule) or Composer update is performed? If so, how do I achieve the requirements with as little fuss for the end user as possible:

  1. A single, optional, freely editable configuration file
  2. Two directories that can contain files that users create
  3. Above alterations stay within the users own version control system and are not removed when a new version is fetched.

Thank you for your patience in advance.

解决方案

What most application frameworks/CMSs are doing these days is to split this process in two packages:

  • one library package (e.g. symfony/symfony, laravel/framework) that contains the bulk of the code, and that will be installed in vendor/
  • one "bootstrap" package (e.g. symfony/framework-standard-edition, laravel/laravel) that contains an application shell that your users can start from. That would contain default config and a composer.json that includes the library package + whatever else is needed in the "require" section. This bootstrap package is typically not updated via composer since it becomes the application/site of your users. Therefore it should contain as little code as possible, and be essentially only configuration.

这篇关于允许opensourced项目的用户将自己的文件添加到他们的副本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆