jeudi 18 janvier 2018

Is the FrontController Pattern relevant for single page app

I am developing an app using KnockOutJS on the front end and PHP on the back-end.

The back-end has two entry points: index.php which contains all the html code and includes all the JS files from knockoutJS and my custom JS files, css etc. The other is main.php, this is where all my AJAX requests go to from my ViewModel, and it us pure PHP.

I don't see how I can make this a single entry app without mixing html and php code in the same file, (index.php). It would be counterproductive to do that because mixing multiple languages in the same file is generally confusing.

My question is, how can I apply a kind of FrontController pattern in this case? The FrontController pattern looks an awful lot like the command pattern. What are its advantages? (other than having a single entry point) How do I split my main.php file up so that I don't have 30 if else statements in a row, one for each kind of request?

Aucun commentaire:

Enregistrer un commentaire