git+ SYMFONY项目服务于多个单独的网站安装
我有一个跟踪Git的Symfony项目,我很快需要复制多个(单独的)姊妹网站。这些站点将具有
- 相同的逻辑;
- 相同的数据库模式;
- 同样的一切,
各个站点之间的唯一区别将是:
- 数据库内容(此处不相关);
- 不同的外观(因此, /模板文件夹和可能 /资产的不同内容)。
当然,为每个站点制作存储库的副本将是一个自杀性的举动,因为逻辑的每个更改或扩展都需要更新每个副本。 我需要将应用程序代码保留为单个GIT存储库,并以某种方式跟踪和管理视图。
我一直在考虑的解决方案是:
- 为每个单独网站的视图创建一个子文件夹: /模板 /site1,..., /模板 /siten
- 停止从主git repo跟踪 /模板文件夹,并处理子文件夹 /模板 /站点<?>作为其他特定于网站的存储库(或根本不跟踪),
- 例如,在.env文件中添加了一个额外的变量,例如。 templates_folder =“/site1”
- 修改了所有控制器,因此,每当加载视图时,
我想将此字符串添加到已求解的路径上? 每当我在特定站点上工作时,我只需编辑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:
- Create a subfolder for the views of each individual site: /templates/site1, ..., /templates/siteN
- 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)
- Add an extra variable in the .env file, eg. TEMPLATES_FOLDER="/site1"
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论