开发者

MVC php/ajax question

I'm developing a php site that displays statistics from an outside site. I drew up this diagram to kind of summarize how the mvc will work. I'm new to implementing the MVC architecture, so could someone tell me if I'm doing this right? I'm thinking that the model is the outside site, and it can't be changed. The controllers are php scripts that parse the data from 开发者_如何学运维the site using a screen scraping class. And then the views are php pages that are displayed using ajax. Take a look at this diagram, the squares are views, the circles are controllers, and there is one model. Is this a mvc architecture? http://img641.imageshack.us/img641/8377/mapym.png


You can use MVC mostly regardless of framework. If you have separate code for data manipulation, separate code for presentation features and separate code using the first two - you have MVC.

I implement it in following way: have data objects supporting CRUD and other operations, have presentation objects accepting data objects as input, have REST/AJAX code to handle requests. It could be supported by a framework, but frameworks should not force you to use it. There's probably no way for framework to prevent you from mixing different tasks in one class or file.

For AJAX MVC seems the most natural. It makes sense to create presentation in JavaScript, while fetching the data using separate PHP module. Everything in between the data and the presentation is a controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜