Yii2 Url Pattern with Id as string not Integer

Hi, i have a REST API that uses uuid as the id of a model. For example, "example.com/items/cvxcv-2312-xcvx-sdfsdf"

unfortunately yii2 treats this as error 404. but if i replace the id with "example.com/items/123" there is a response

i tried to change in the web.php file url manager but i’m still figuring it out. I need help. Thanks

It is right because item detail accept a number (\d+) as parameter.

Check the urlManager in config/main.

The rules for the url manager must treat UUID as a string, because it has ‘-’ and ‘a’ to ‘f’.

Does your model have a corresponding UUID other than id?

If yes, you could retrieve the id from the UUID.

can’t find the syntax in urlmanager to have this pattern. the docs is not clear. can’t also find in stackoverflow

my url manager


'urlManager' => [

            'class' => 'yii\web\UrlManager',

            'showScriptName' => false,

            'enablePrettyUrl' => true,

            'rules' => [

                [

                    'class' => 'yii\rest\UrlRule',

                    'controller' => ['item'],

                    'pluralize' => true,

                ],


            ]            

        ],

found on the forums tried this works on uuid but better if the length of each uuid string is specified


[

                    'class' => 'yii\rest\UrlRule',

                    'controller' => ['item'],

                    'pluralize' => true,

                    'tokens' => [

                        '{id}' => '<id:\\w+-\\w+-\\w+-\\w+-\\w+>'

                    ]

                ],