git+ SYMFONY项目服务于多个单独的网站安装

发布于 2025-02-10 07:00:25 字数 850 浏览 1 评论 0原文

我有一个跟踪Git的Symfony项目,我很快需要复制多个(单独的)姊妹网站。这些站点将具有

  • 相同的逻辑;
  • 相同的数据库模式;
  • 同样的一切,

各个站点之间的唯一区别将是:

  • 数据库内容(此处不相关);
  • 不同的外观(因此, /模板文件夹和可能 /资产的不同内容)。

当然,为每个站点制作存储库的副本将是一个自杀性的举动,因为逻辑的每个更改或扩展都需要更新每个副本。 我需要将应用程序代码保留为单个GIT存储库,并以某种方式跟踪和管理视图。

我一直在考虑的解决方案是:

  1. 为每个单独网站的视图创建一个子文件夹: /模板 /site1,..., /模板 /siten
  2. 停止从主git repo跟踪 /模板文件夹,并处理子文件夹 /模板 /站点<?>作为其他特定于网站的存储库(或根本不跟踪),
  3. 例如,在.env文件中添加了一个额外的变量,例如。 templates_folder =“/site1”
  4. 修改了所有控制器,因此,每当加载视图时,

我想将此字符串添加到已求解的路径上? 每当我在特定站点上工作时,我只需编辑templates_folder变量,就像切换看起来很快,因此我可以在特定的视图上或仅在主要的公共应用程序上工作。 在单个生产站点上,我什至可以将特定的模板直接放在 /模板下,并在.env文件中设置templates_folder =“”:它具有标准符号安装的相同行为。

我对此没有任何问题,但是我是一个亲戚的初学者,我没有在网上找到这样的东西,所以我怀疑事情可能比我想象的要复杂得多,而且我缺少一些东西。 在进行调整项目之前,我想听听一些意见。

非常感谢

I have a Symfony project tracked with Git which I will soon need to duplicate for making multiple (separate) sister websites. These sites will have:

  • same logic;
  • same database schema;
  • same everything

The only differences between the individual sites will be:

  • database contents (not relevant here);
  • different look (therefore different contents of the /templates folder and probably /assets too).

Of course making copies of the repository for every site would be a suicidal move, as every change or extension to the logic would require every copy to be updated.
I need to keep the application code as a single Git repo, and track and manage the views somehow differently.

The solution I have been thinking about is the following:

  1. Create a subfolder for the views of each individual site: /templates/site1, ..., /templates/siteN
  2. Stop tracking the /templates folder from the main Git repo, and treat the subfolders /templates/site<?> as additional site-specific repositories (or don't track them at all)
  3. Add an extra variable in the .env file, eg. TEMPLATES_FOLDER="/site1"
  4. Modify all the controllers so whenever a view is loaded, such string is added to the path

Solved, I think?
Whenever in development I am working at a specific site, I just edit the TEMPLATES_FOLDER variable and it's like switching looks very quickly, so I can work at the specific views, or just at the main common app.
On the individual production sites I can even put the specific templates directly under /templates, and set TEMPLATES_FOLDER="" in the .env file: that would have the same behaviour of a standard Symfony installation.

I don't see any problem with this, but I am a relative beginner and I haven't found anything like this online, so I suspect things may be more complicated than I think and I am missing something.
Before I proceed tweaking my project I would like to hear a few opinions.

Many thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文