如何在PHP中合并两个MVC系统?
我正在使用两个需要合并的 MVC 系统。看来两者都使用不同的会话变量和不同的 cookie。我遇到的主要问题是试图让每个人来回传递会话变量,但它不想这样做。
合并两者的最佳方法是什么?
更新:我正在尝试 BlueImp 聊天 与另一个从头开始编写的 MVC。会议进行得并不顺利。
I am working with two MVC systems that need merged. It appears both use different session variables and different cookies. The main problem I have is trying to get each one to pass sessions variables back and forth, which it does not want to do.
What is the best way to go about merging the two?
Update: I am trying BlueImp chat with another MVC that is written from scratch. The sessions are not playing nicely.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了其他人所说的之外,这听起来像是一个糟糕的主意。如果您真的想这样做,最好的方法是集成每个 MVC 的每个模块。
IE。将模型以及控制器和视图集成到一个固化单元中,最终结果是一个符合您自己口味的混合 MVC。
发布一些代码也许有人可以帮助解决这个问题。
Aside from as others have said this sounds like a baddd idea. The best route to take if you REALLY want to do this would be to integrate each module of each MVC.
Ie. integrate the models into one solidified unit, as well as controller and views and the end result is a mashed up MVC of your own taste.
Post some code perhaps someone can help work through this.
事实证明,是的,你不想尝试这个,特别是如果两者之间混合了 javascript。
a) 会话合并:
BlueImp 使用平面文件进行用户访问。这很快就被跟踪并重新路由到登录功能中的正确用户表。
b) 输出控制
由于 blueImp 使用 XML 进行输出,因此使用 jQuery div 控制器根本不起作用。所以我被迫使用可怕的 IFRAME。这在某种程度上是有效的。任何参数都必须使用 GET 变量传递。
c) IE,可怕的 DOM 解析。
很抱歉,一个 JavaScript 错误会导致所有进一步的代码执行崩溃。换句话说,如果父页面产生错误,IFRAME 可能会失败。抑制错误报告目前仅有效。
结果 混合 MVC 是可能的,但前提是您能够正确平衡上述所有三者。不幸的是,在这个项目中,太多的 JavaScript 错误阻碍了砖墙的正常运行。此外,不幸的是,没有其他解决方案,因为聊天应用程序非常需要正确的 AJAX 握手才能正常工作。如果父 MVC 崩溃了,它会向下传递所有其他内容。
我的结论是,MVC 很好,但是 PHP 函数库更好...(以及 99% 的 PHP 语言集的工作原理。)
是的,不是一个完整的解决方案,但希望这会帮助任何其他尝试这样做的人做这个。
Turns out yes, you don't want to try this, especially if there is javascript mixed between the two.
a) session merging:
BlueImp uses a flat file for user access. This was quickly traced and re-routed to the correct user table in the login function.
b) output control
since blueImp uses XML for output, using a jQuery div controller simply doesn't work. So I was forced to use the dreaded IFRAME. This works.. up to a point. Any parameters must be passed with GET variables.
c) IE, the dreaded DOM parse.
So sorry, but a single javascript error crashes any and all further code execution. In other words, IFRAMEs can fail if the parent page spawns an error. Suppressing error reporting only works so far.
RESULT it is possible to mix MVCs, but only if you can properly balance all three of the above. Unfortunately, with this project, too many javascript errors blocks the proper functioning with a brick wall. Also, unfortunately, there is no other solution, since chat apps seriously need proper AJAX handshaking to work properly. And well if the parent MVC is crashy, it casades downwards through everything else.
My conclusion, MVCs are nice and all, but PHP function libraries are much nicer... (and also how 99% of the PHP language set works.)
Yes, not a complete solution, but hopefully this will help anyone else that attempts to do this.