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.
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 m开发者_如何学Pythonore complicated than SELECT * FROM entity_name
.
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.
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.
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.
精彩评论