Using laminas-router regex with a Mezzio application

I have this route set up, which works OK, but I’d like to know if it’s possible to make a route that captures /s in a parameter

Right now I have

return static function (Application $app): void {
//...
$app->get(
    sprintf(
        '/img/store/:%s/:%s/:%s[/:%s]',
        App\Handler\ImgStoreHandler::PART_1_ATTRIBUTE,
        App\Handler\ImgStoreHandler::PART_2_ATTRIBUTE,
        App\Handler\ImgStoreHandler::PART_3_ATTRIBUTE,
        App\Handler\ImgStoreHandler::MANIPULATIONS_ATTRIBUTE
    ),
    [
        ProblemDetailsMiddleware::class,
        App\Handler\ImgStoreHandler::class,
    ],
    'img'
);

But ideally, I’d like something like

$app->get(
    sprintf(
        '/img/store/:%s',
        App\Handler\ImgStoreHandler::PATH_ATTRIBUTE,
    ),
    [
        ProblemDetailsMiddleware::class,
        App\Handler\ImgStoreHandler::class,
    ],
    'img'
);

where I can set regex to match with the parameter.

Is this possible with laminas-router?

I figured it out :slight_smile:

$app
    ->get(
        sprintf(
            '/img/store/:%s',
            \App\Handler\ImgStoreHandler::PATH_ATTRIBUTE
        ),
        [
            ProblemDetailsMiddleware::class,
            \App\Handler\ImgStoreHandler::class,
        ],
        'img'
    )
    ->setOptions([
        'constraints' => [
            \App\Handler\ImgStoreHandler::PATH_ATTRIBUTE => '[a-zA-Z\d]{2}/[a-zA-Z\d]{2}/[a-zA-Z\d]{36}/?.*',
        ],
    ]);