How can I do 'or' in the route?
for instance, /about
and /fr/about
are pointing to the same objects/classes/methods. So instead of:
$app->get('/{url:[a-zA-Z0-9\-]+}', function (Request $request, Response $response, array $args) {
// same staff
});
$app->get('/{language:[fr|en]+}/{url:[a-zA-Z0-9\-]+}', function (Request $request, Response $response, array $args) {
// same staff
});
I tried with this:
$app->get('/{url:[a-zA-Z0-9\-]+}|/{language:[fr|en]+}/{url:[a-zA-Z0-9\-]+}', function (Request $request, Response $response, array $args) {
// same staff
});
I get this error:
Type: FastRoute\BadRouteException
Message: Cannot use the same placeholder "url" twice
File: /var/www/mysite/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php
Any ideas what how to resolve this issue?
Or any solutions to avoid repeating the code?