多个 MVC 应用程序、相同的模型和数据库、不同的控制器、视图和域
我的任务是重建四个电子学习 Web 应用程序 (PHP MVC),用于处理购买/销售并与在线课程交互的公司和用户:
- “霸主”应用程序,在其中创建公司帐户,汇总所有帐户的报告 “企业”应用程序
- ,其中较大的组织管理其子公司,并可以访问所有上述公司的汇总报告。
- 电子商务应用程序,公司和个人可以在其中购买和销售课程。
- “基础”应用程序,公司的用户可以与公司创建或购买的课程进行交互。这里也是由“讲师”创建用户和课程的地方,“讲师”基本上是具有高级管理权限的用户。
当然,所有这些应用程序都有不同的界面,并且可以在不同的域上访问。
至此,应用4已完成。
我的问题是,以前的开发人员重复了大量代码,并且只在应用程序之间共享数据库,导致需要更改某些内容时造成维护混乱。
这些应用程序有很多共同点。它们都处理相同的课程、用户和公司,从 4 到 1,每个应用程序基本上都能更全面地了解正在发生的事情。
例如,在应用程序 4 中,有当前公司的课程完成情况和电子商务报告(只有部分用户可以访问)。上至应用程序2,汇总属于同一企业的公司的报告,再往上,在应用程序1中,呈现所有企业和独立公司的报告。此外,每个都有一些不同的独特功能。
因此,对我来说,所有应用程序都应该共享相同的模型,并且每个应用程序都应该有自己的控制器和视图,这似乎很自然。我的问题是:
从技术上讲,最好的方法是什么?这些应用程序位于同一服务器上,每个应用程序位于不同用户的 /home 目录中,并且 open_basedir 限制有效,每个应用程序只允许包含其目录中的文件。
我应该放宽 open_basedir 限制并允许包含模型位置中的文件,这会对安全产生哪些影响?我们拥有服务器,因此进行任何更改都不是问题(尽管运行 Plesk 意味着我们应该从其界面进行所有配置)。
如何配置域?
我现在“视情况而定”,但这实际上是一个好主意吗?我可以看到,所有应用程序的功能都存在模型过度拥挤的风险(尽管我肯定会在必要时分离应用程序逻辑)。
I am tasked to rebuild four e-learning web applications (PHP MVC) that deal with companies and users that buy/sell and interact with online courses:
- The "overlord" application, where company accounts are created, reports are aggregated for all the accounts throughout all the other applications, etc.
- The "enterprise" application, where a larger organization manages it's children companies and has access to aggregated reports for all said companies.
- The eCommerce application, where companies and individuals buy and sell the courses.
- The "base" application, where a company's users get to interact with the courses created or bought by their company. Also here is where the users and courses are created, by "instructors", which are basically users with elevated management rights.
All of these applications have different interfaces of course, and are accessed on different domains.
As of this moment, application 4 is done.
My issue is that the previous developers duplicated a lot of code and only shared the database between applications, resulting in a maintenance mess when something needed to be changed.
The applications have a lot in common. They all deal with the same courses, users and companies, and going from 4 to 1, each application basically gets a bigger picture of what is happening.
For example, in application 4, there are course completion and eCommerce reports for the current company (which only some users can access). Going up to application 2, the reports for companies belonging to the same enterprise are aggregated, and further up, in application 1, the reports for all the enterprises and stand-alone companies are presented. Besides, each has some different piece of unique functionality.
So it seems natural to me that all the applications should share the same models, and each application should have it's own controllers and views. My questions are:
What would be the best way to do this technically?. The applications are on the same server, each one in a different user's /home directory, and open_basedir restriction is in effect, with each application only being allowed to include files from it's directory.
What are the security implications should I relax the open_basedir restrictions and allow the inclusion of files from the models' location? We own the server, so making any changes is not a problem (although running Plesk means that we should do every configuration from it's interface).
How could I configure the domains?
I now "it depends", but is this actually a good idea? I can see that there is a risk of overcrowding the models with functionality for all the applications (although I will surely separate applications logic where necessary).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果应用程序位于同一服务器上。我将为其中一个域创建一个主帐户,并将其余域放置在该帐户之上。
并让应用程序根据域确定应用程序需要加载。
您也可以采用这种结构
,并将域放置在文件夹domain1、domain2等上...并且在该索引中您可以相应地设置模型、控制器和视图路径。
这样您就可以通过域(对于本地测试环境)访问应用程序。
If the applications are on the same server. i would make the a master account for one of those domains and park the rest of the domains on top of that.
and have the application determine witch applications needs loading based on the domain.
Also you could go for this structure
And you park the domains on the folders domain1, domain2 etc ... and in that index you could set the models, controllers and views path accordingly.
This way you have a way of accessing the application with ought the domain ( for local, testing enviroments ).