Route Here, Route Now
Routing within a web framework has always been up for debate in my eyes. Until recently.
It dawned on me that a simple routing system would be pretty flexible. At its most basic level, routing is just converting one string into another. Regular expression functions are built for exactly this sort of thing. In fact, most routing libraries perform some sort of regular expression matching.
That’s why I set up Routes as a separate library. It’s a low-level class that performs the most basic functions: collate a series of patterns (routes) and provide a way for given strings to be tested against them.
Routing libraries in other frameworks mean more than this though; routes are specifically tied to controllers and actions. In Eddy, routing is automated - you don’t need to define routes to help the framework figure out what controller and action to use.
But sometimes you do need routes. Up until now, for Eddy, you’d have to do this with a .htaccess file. This can get unwieldy. We’ve found this more and more - especially when writing apps that need to work in multiple environments (dev, testing, production etc). This often resulted in duplication of rules and got very messy.
The other issue with .htaccess is that it’s Apache-specific. We’re hoping to use Eddy on other web servers soon so we can’t rely on .htaccess rules forever. We need to move URL rewriting into the application space.
The other upside to this is that we can now do use our routing rules without having to fire up a HTTP request. We can use the Routes library and the routes we’ve set up internally at any point in the application to see what the result of our rules will be against a given string. mod_rewrite rules come just too early for that sort of convenience.
These reasons have convinced me that in-app routing is the way forward and I’m pleased to say we’ve incorporated it very simply into Eddy. Of course we still rely on mod_rewrite to make sure all requests that don’t resolve to an actual file get pushed through the application. But that sort of functionality is available in most web servers now, so it’s another step towards being portable.
Keep checking the roadmap for the latest upcoming features. If there’s something you’d really like us to implement, be sure to let us know!
-
frameworkawesome posted this