Difference Between Frontend and Backend MVC

Despite doing slightly different things, both the frontend and the backend of Joomla use the Model View Controller design pattern for organizing code. The biggest difference is that the frontend is primarily used for displaying data while the backend is used for managing it.

So the first difference is that you can usually get away with a single controller in the frontend, and you usually cannot get away with a single controller in the backend. In the frontend, nine times out of ten, you're just displaying a view, you're not going to have as many forms as you have in the backend and you aren't going to be taking in as many specific requests from users.

So second difference between the frontend and the backend is that the backend has some controllers and models that are a little bit more suited for loading and saving and deleting records. It makes this process a little bit more automatic than it would be if you didn't have these specialized controllers.

The third difference is that the security model in a backend is very different. When you have logged into the backend of the web site, it's necessary to make sure that another web site that you're visiting is not trying to make a request on the backend instead of you making that request. It's a security hazard that's known as a Cross-Site Request Forgery, and the only way to protect against this is to send a randomized token to the form and have that token checked whenever that form gets submitted.

Then finally, the HTTP request flow is different in the backend. When you save, delete or otherwise change a record, you're going to be redirected by the controller to another screen in Joomla This is so when you hit the Back button, you don't accidentally do that save or delete again, and this differs from the frontend in that the frontend is simply displaying a view and that's the end of it. With the backend, whenever you do one of these tasks, it's going to complete the task and then redirect you to another screen.

So while the code in Joomla's! backend serves a different purpose from the code in the frontend, the same MVC design pattern applies. However, security and data management considerations make it necessary to take different approaches with similar looking code.

close