Configure Silex Routes with optional parameters

routes, silex

Solution

Okay, i could easy fix that by my own. Here is my solution:

$app->match ( '/controller/param/{q}', "demo.controller:demoAction" )->value ( 'q', false )->bind ( 'demo_action_without_country' );
$app->match ( '/controller/param/{country}/{q}', "demo.controller:demoAction" )->value ( 'country', false )->value('q', '')->bind ( 'demo_action_with_country' );

Problem

I have configured these 2 routes ``` $app->match ( '/controller/param/{country}/{q}', "demo.controller:demoAction" )->value ( 'country', 'de' )->value('q', '')->bind ( 'demo_action_with_country' ); $app->match ( '/controller/param/{q}', "demo.controller:demoAction" )->value ( 'q', '' )->bind ( 'demo_action_without_country' ); ``` However - this does not work. If i call `/controller/param/Test-String` the route matches and returns content. If i call `/controller/param/DE/Test-String` i get NotFoundHttpException How can i solve the problem?

Original source