Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



3.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 :)