Table: url_alias
+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
| id | slug | map_to | params | http_verb | middleware |
+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
| 1 | page/about-us | Frontend\HomeController@showPage | a:1:{i:0;i:4;} | GET | web |
| 2 | page/contact-us | Backend\DashboardController@getContactUs | a:1:{i:0;i:4;} | GET | web |
| 3 | page/contact-us | Backend\DashboardController@postContactUs | | POST | web |
+----+-----------------+-------------------------------------------+-----------------+-----------+------------+
- slug: self explanatory
- map_to: Namespace (if any) Controller @ method
- params: should be serialized array
- http_verb: register routes with http verb (GET|POST|DELETE|PUT|ANY)
- middleware: to wrap routes under specified middleware group
Inspired from philsown/53bc22d001db979481e4, i didn't want to run db query on each request thats why file generation method is the rescure here, call route-generation functionality after change made on url_alias table.
Any suggestions will be appreciated.
I love this approach but why not to just cache the routes rather than creating php code?