我正在用 php 制作一个解决方案,并且正在考虑为不同的客户端进行多次安装。如果我有 20 个数据库,将它们指向同一个 php 代码库有什么问题吗?例如。速度问题,还是不好的做法?
提前感谢您的想法和专业知识:-)
我正在用 php 制作一个解决方案,并且正在考虑为不同的客户端进行多次安装。如果我有 20 个数据库,将它们指向同一个 php 代码库有什么问题吗?例如。速度问题,还是不好的做法?
提前感谢您的想法和专业知识:-)
这是可能的,不会影响你的表现,但它有一个缺点。
如果您有一个代码库,这意味着您必须在更新它时重新检查所有客户端是否有错误。因此,您的客户最好将代码库分开,这样您就可以为特定客户端更新代码库并防止其他客户端出错。
如果一切似乎都适用于一个客户,您可以考虑对另一个客户进行相同的更新。
如果您为每个客户端都有自定义代码,就会出现这种情况,如果它是一个像邮件管理系统这样的应用程序,
那根本不是一个坏习惯。
如果您为每个客户端分配了一个版本号,那就太好了。这使得可以在单个客户端上测试新版本,并慢慢将其他客户端迁移到更新版本
I would say the opposite from Visser. If there is a bug in one installation, then the same bug is going to exist in all installations unless you provide customized versions of your software. Sure, different customers might use the applications in different ways, hence some might never experience a defect that brins the business of another customer to a grinding halt. Hence I disagree with Viseer again that it won't affect performance - differences in usage could lead to very marked differences in overall performance for a particular customer, but tuning at the PHP tier will benefit all customers. Tuning at the database tier is a slightly different story - some customers might benefit from an index that would slow down other customers.
If you do provide per-customer variations in the behaviour of your code, then how you do this depends on the complexity of those variations. Ideally the differences should be described in the database, and the same PHP code would then produce different results - e.g. one customer wants a standalone user-management and authentication system, another customer wants to use LDAP authentication, a third OpenID - in which case your code should implement all 3 and the method chosen at runtime based on the data.
Sometimes (but rarely) it's not practical to implement this approach and using different application logic for different installations is the solution. In this case, the right approach is to maintain a fork in your version control system. An example would be different branding on the site - unless you're developing on top of a content management system, then it's probably simpler to use different CSS files (I'm struggling to think of an example where different PHP code is justified).