Reputation: 1554
I'm looking into using F3 for more of my projects. I love the routing feature and the ability to produce dynamic routes for using with conventions like:
$f3->route('GET /@controller/@action', '@controller->@action');
One thing I need is seo-friendly URLs so I can do something like:
/two-words/two-more-words
as a controller/action combo. I've tried this in code as well as searched as far as I can see for examples on how to accomplish this, but thus far, I've been unsuccessful. Basically, the dash in the url will not resolve to a class/method (controller/action) combo in the routes.
Is there a way to do this so that dashes either get replaced by empty characters or some other way to get the routes to resolve?
Upvotes: 0
Views: 389
Reputation: 2052
well if you really want it that way you could use a lambda function for this:
f3->route('GET /@controller/@action', function($f3,$params){
$class = str_replace('-','',$params['controller']);
$method= str_replace('-','',$params['action']);
$f3->call( $class.'->'.$method );
});
Upvotes: 0