架构:多个网站。一个代码库。自定义代码

发布于 2024-11-30 02:00:46 字数 437 浏览 0 评论 0原文

好的。我目前正在构建一个 php 应用程序(平台),该应用程序将被部署多次,只是使用不同的配置。该应用程序由后端和前端组成。通过后端,我们可以配置哪些模块处于活动状态、设置是什么以及平台的外观。

我们预计客户将开始要求其平台上的特定功能。这意味着该平台将与其他平台不同。但是,我们维护一个代码库。

解决这个问题的最佳方法是什么?由于我们不断修复错误并开发新功能,因此应该很容易照顾所有平台。我们有一个脚本,用于将平台更新部署到所有平台。

我们是否应该将所有功能转换为插件,以便每个平台都可以根据需要手动更新?因此,如果客户想要与原始插件不同的东西,我们复制该插件并创建他们自己的客户插件?但是,如果我们决定更新插件,代码是否容易维护?

或者我们应该在代码中为每个客户编写异常吗?

我们是否应该有单独的文件来使用自定义代码覆盖每个平台的基本文件?

最好的方法是什么?

Okay. I am currently building an php application (platform) which will be deployed multiple times, only with different configurations. The application consists of a backend and frontend. Through the backend, we are able to configure which modules are active, what there settings are and how the platform looks like.

We expect that customers will start asking for specific functionality on their platform. This means that there platform will be different then the other ones. But, we maintain one codebase.

What's the best way to solve this? Since we keep on fixing bugs and developing new features, it should be easy to take care of all the platforms. We have a script which we use to deploy our platform updates to all our platforms.

Should we convert all our functionality into plugins so every platform can be updated manually if they want? So if a customer wants something differently then the original plugin, we duplicate the plugin and create their own customer-plugin? But is the code easily to maintain then if we ever decide to update the plugin?

Or should we write exceptions in the code for every customer?

Should we have separate files which override the base files for every platform with custom code?

What's the best way to go?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流殇 2024-12-07 02:00:46

最大的技巧是平衡客户的不同需求,而不会最终导致无法维护的极其复杂的系统。您应该考虑以下几种方法:

  • 依赖倒置:关于这个主题有很多的材料,基本上它是一种构建系统的方法,以便系统中的不同部分依赖于概念而不是具体的实现。这将允许您为不同的客户交换这些实现。它可用于从深层业务逻辑和算法到数据提供程序再到 UI 小部件的所有内容。我不确定从 DI 开始的最佳位置(我来自 .Net 背景,而不是 PHP 背景),所以 这是维基百科条目作为开始。
  • 确定用户想要更改的事物类型,并将这些事物隔离为可以使用 DI 或其他实用方法轻松替换的事物。完成此操作后,请非常努力地不要在框架代码库(基本上“托管”可交换位的核心)中引入变化。
  • 尽可能保持依赖关系树干净。
  • 从 PoC / 原型开始。构建框架非常困难。您的第一次尝试可能会成功,但您的第二次和第三次尝试会更好;
  • 在开发期间和部署之后,花一些精力使系统易于测试,您将需要良好的诊断。帮助您隔离问题并提供帮助 编辑

:最后,如果您还不了解它们,您可以使用或简单地借用一些现有的 PHP 框架 - PHP 开源社区相当强大。查看 Zend 框架。

The big trick will be balancing the diverging needs of customers without ending up with a massively complex system that is impossible to maintain. Here's a few approaches you should consider:

  • Dependency Inversion: there's lot of material on this subject, basically it's a way of structuring a system so that different parts within it depend on concepts rather than concrete implementations. This will allow you to swap those implementations for different customers. It can be used for everything from deep business logic and algorithms to data-providers to UI widgets. I'm not sure where the best place is to start with DI (and I come from a .Net background not a PHP one) so here's the Wikipedia entry as a start.
  • Identify the sorts of things users will want to change and isolate those things into things which can easily be swapped out using DI or some other practical approach. Having done that try very hard not to introduce variations into the framework code-base (the core that basically "hosts" the swappable bits.
  • Keep the dependency tree as clean as possible.
  • Start with a PoC / Prototype. Building frameworks is very hard. Your first attempt might work ok but your second and third attempts will be better; experience counts for a lot.
  • Put some effort into making the system easy to test, both during development and after deployment. With all the moving parts you will want good diagnostics to help you isolate issues and help with integration.

Edit: Finally, if you're not already aware of them, there are existing PHP frameworks that you might be able to use or simply borrow approaches from - the PHP Open Source community is fairly strong. Check out the Zend Framework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文