[Solar-talk] front controller + router, round 2

Rodrigo Moraes rodrigo.moraes at gmail.com
Fri Jul 6 09:36:20 CDT 2007


Hi,
I wish you could take a look this, not for Solar exactly, but to see
how nice it can be to mix a routing mechanism a la Rails/ZF with
Solar_Controller_Front, falling back gracefully to
Solar_Controller_Front when necessary:

    http://dev.tipos.org/browser/trunk/Tipos/Controller/Router.php

The "matching routes" parts came from ZF, but the rest is
Solar_Controller_Front plus a list of route objects.

My previous try was much more complex (and ugly); I tried to mimic ZF
not with much success. After several months I resurrected it, put it
back to trunk an started a refactoring: subclassing
Solar_Controller_Front made it much more simple and with nice
fallbacks.

Now, with 'compat' config set to true and adding a default route
':controller/:action/*', you can get the Hello World / Bookmarks app
working using... routes. Or just not set any routes and fallback to
Solar_Controller_Front. :)

But the nice parts are the named parameters arriving in the page
controller, and the possibility to set 'modules' in routes to map to
App/Module/Controller. Yay!

Let me know if you think it is useful and how we can improve it. :)

-- rodrigo


More information about the Solar-talk mailing list