MVC风格的应用程序体系结构餐饮API [英] MVC style application architecture catering to API

查看:104
本文介绍了MVC风格的应用程序体系结构餐饮API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个社区式的网站,无论是为乐趣和利润,虽然它的美学元素是很好的磨磨蹭蹭,我还没有沉没我的牙齿进入工作出应用程序逻辑的理由unsureness在我的方法。

I'm working on a "community" style website, both for fun and profit, and while the aesthetic element of it is coming along nicely, I haven't yet sunk my teeth into working out the application logic for reasons of unsureness in my approach.

我创建一个PHP驱动的MVC框架的风格,我希望能够重复使用的组件,但我注意到,许多现有的MVC框架使用了一种约定优于配置,以加快整个过程。某些查询​​我打算跑比稍微复杂SELECT * FROM ENTITY_NAME

I'm creating an PHP powered MVC style framework which I can hopefully reuse components of, however I've noticed that many existing MVC frameworks use a sort of "convention over configuration" to expedite the whole process. Some queries I intend to run are a little more complicated than SELECT * FROM entity_name.

我想设计在层应用,使API调用,可以向服务器。我想,而不是做的一切两次,我会建立自己的地盘在该层的顶部,让一切都按照一个标准。这将允许Ajax调用,远程Web应用程序调用等,按照规范化的要求和响应的文件Web请求的相同的路线。

I want to design the application in layers, so that API calls can be made to the server. I figured instead of doing everything twice, I would build my site controllers on top of this layer, so that everything follows a standard. This will allow Ajax calls, remote web application calls, etc., to follow the same route of request normalization and response as document web requests.

不管怎么说,也许很多是不必要的细节,但任何人都可以揭示这种性质的API分层MVC架构一些轻?由于API级别(模型层)就是数据最终读/写的,我会想将认证在这个水平上,或抽象到一个更高的水平,使该入口点?我应该说我没有提到其他什么方面的考虑?

Anyways, perhaps much of that is unnecessary detail, but can anyone shed some light on API layered MVC architectures of this nature? Since the API level (the model layer) is where data is ultimately read/written, would I want to incorporate authentication at this level, or abstract it to a higher level and make that the entry point? What other considerations should I make that I haven't mentioned?

我知道我还有很多读书的事,阅读材料或意见,使任何建议从个人的经验,这是非常可喜的。先谢谢了。

I know I still have much reading to do, so any suggestions for reading materials, or advice from personal experience with this is very welcome. Thanks in advance.

推荐答案

这是一个很好的问题。我想我最好的选择是使用与REST资源的SOA方法尽可能如果您的网站获得了大量的点击率,但可能值得分离状态的状态暴露变异,因此第一个可以使用更复杂的面向对象的方法,而其他可以使用简单的DTO(在阵列的形式),并通过使用自定义查询从数据库中检索的数据。

This is a very good question. I think my best bet would be to use an SOA approach with REST resources as much as possible If your website gets a lot of hits, it might be worth segregating state mutating from state exposing, so the first can use a more complex OO approach whilst the other can use simple DTOs (in the form of arrays) and retrieve the data from the database by using custom queries.

这篇关于MVC风格的应用程序体系结构餐饮API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆