Re:Link: A fast and simple PHP Router
by bartonfink on Thursday May 29, 2014 @12:27PM
(#7817014)
It would help decouple your application code and structure from Apache configuration and the need to be familiar with Apache configuration syntax and nuance. Your Apache config would just need to route all requests to your app root to one routing file, which is pretty simple, and then the routing file can process from there. You'd also have the benefits of more configurable routing, if you needed that (e.g. routing based on specific parameters in a POST instead of just based on the request url and method).
Re:Link: A fast and simple PHP Router
by Nickoladze on Thursday May 29, 2014 @12:44PM
(#7817129)
I would prefer to have all my behavior be in my codebase.
Also, restarting Apache after adding a route would get tedious during development.
I guess you are asking why not just use the filesystem one-one like mapping url to file?
A benefit of routing is that you can have a single point of contact in your app: a front controller. And you can place your route config in one place.
This router also has RESTful routing, detecting HTTP methods upfront that correspond to a predictable method name in a named class.
Overall, I'm not trying to discount anyone's work with developing PHP routers, but I'd like to understand the benefits of using them.