The Dispatcher in QloApps manages redirection of URLs i.e. QloApps uses one file
index.php only instead of using multiple files like
product.php in the root folder.
The dispatcher handles all the requests in QloApps. It is responsible for loading and executing the controller.
Further, friendly URLs or URL rewriting is also supported by the dispatcher.
Friendly URL can be enable/disable from Preferences -> SEO & URLs page in the admin back office. If friendly URL is disabled in QloApps looks like below in case of URL-rewriting is off -
When you enable URL-rewriting in QloApps the URLs will look like below -
In QloApps there are many advantages of using dispatcher:
- To add a controller is easier.
- For better SEO, you can change your friendly URLs by using custom routes.
- There is only one single entry point into the software, which improves software's reliability and makes future developments easier.
loadRoutes() method (by overriding) new routes can be easily created.
Three abstract classes: Controller, FrontController and AdminController are used by the dispatcher. (FrontController and AdminController inheriting from the Controller).