We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Routing regex isn't parsing correctly for this pattern

I might be doing this the wrong way altogether, I wanted URI to look like : api/project/start:2015-10-20/end:2016-11-22

$app->get('/api/project/start:{started:(([\d]{4})(-[\d]{1,2})?(-[\d]{1,2})?)}/end:{ended:(([\d]{4})(-[\d]{1,2})?(-[\d]{1,2})?)}',
    function ($id, $started, $ended) use ($app) {
        echo $id,'<br>'; // 123 - correct
        echo 'start ', $started,'<br>'; // 2015-10-20 - correct
        echo 'end ', $ended,'<br>'; // 2015 - WTF??
    }
);

The started: and ended: regex are identical, phalcon gets the $id, and $started portion correctly, but $ended returns part of $started. The regex is correct, I've checked.



5.7k
Accepted
answer
edited Mar '16

figured it out, just do parsing elsewhere

$app->get('/api/project/start:{started}/end:{ended}', function($started, $ended) { ... });

Edit: Actually, sure I thought of a different way to do it, but the Phalcon pattern parsing problem remains.

Mark your answer as solved to help others :)