i’ve got a project in php-silex, but i beging with this framework.
I create some route but some doesn’t work.
Here some exemple:
/*
**INIT HERE & SOME OTHER CODE
*/
$app->match('letter-{letter}', function($letter) use()
{
echo 'With dash';
});
$app->match('letter_{letter}', function($letter) use()
{
echo 'With underscore';
});
$app->match('{other}', function($other) use()
{
echo 'Other view';
});
If i enter /letter-a the output is ‘Width dash’ but if i enter ‘/letter_a’ the output is ‘Other view’ and not ‘Width underscore’.
I want to known why this happened and how to show ‘Width underscore’ ?
The problem is that the routes:
letter-{letter}andletter_{letter}resolve to the same route name, thus the second one overrides the first. The solution is to explicitly give the routes a unique name.You can do that by using
bind:I’ll open a ticket on the silex tracker to see if we can give an error when two routes with the same name exist. (EDIT: done)