Controller
The first thing that a new request interacts with is the controller. As mentioned previously, the controller handles routing a request, coordinating the model to process the data, and then utilizing the view to get a response, which can then be returned. It acts as the outermost layer of your application.
Front controller
Within the MVC pattern there is another commonly used pattern called the Front Controller. This is the single point of entry for all web requests. Generally the Front Controller should be lean and delegate all actual work to specific controllers for specific requests.
The front controller's job is to take every single inbound request and decide what to do with it.
In some frameworks or applications, the front controller may handle all "Controller" level duties. However, in ToyMVC
, we have decided to have discrete controllers for each section of the app. This keeps our classes small, allows us to stick to SOLID principles, and...