In the last chapter, we put together the code for basic routing. It’s time to package this code up in a way that we can reuse and extend.
What Routers Are Used For
Before we can build a good router, we need to try and understand the problem. When PHP first started out, it was common for applications to rely heavily on the file-based routing that web servers offered.
File-based routing is where you have different files for each URL your website responds to. Say you had a webroot/pages/edit-page.php file; file-based routing would expose that as http://your-website.com/pages/edit-page.php ...