Hi!
I am writing application in PHP (+ MySQL database), but it gonna be mainly AJAX aplication. So, I am wondering, how to create frontend? Frontend also in MVC? Is it possible?
Hi!
I am writing application in PHP (+ MySQL database), but it gonna be mainly AJAX aplication. So, I am wondering, how to create frontend? Frontend also in MVC? Is it possible?
Of course MVC is possible on the front end also. JavaScript is a rich programming language, and since MVC is only a design architecture it's language agnostic. There are some attempts at MVC in some JS frameworks, mainly sproutcore and JavaScriptMVC.
I guess there are two paths to go, either separate PHP and frontend completely, and just pass JSON or XML with ajax between them, or blend them like a classic web application, and do some ajax-requests on top of that.
Unfortunately it is still not a good idea to rely on JavaScript being enabled, so having JavaScript applications "fail" gracefully is preferred.
I would recommend creating a basic PHP/HTML click-and-reload application first, which would allow dinosaurs to use the basic features of the site, and then build a JavaScript/AJAX application on top of that, which would enhance the base application.
As to the MVC question: It is definitively possible to create a JavaScript MVC front-end. I tried it myself a few months ago and it worked great. Just keep a close eye on the scope of your function calls. They can get away from you if you aren't careful :-P