We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How to get parameters from the URL with Phalcon\Mvc\Micro\Collection

I use Phalcon\Mvc\Micro\Collection to set up routing .here is my code:

    use Phalcon\Mvc\Micro\Collection;

    return call_user_func(function () {
        $rules['grade']     = new Collection();
        $rules['grade']->post('/{classId:[0-9]+}/apply', 'apply');
        return $rules;


    namespace Api\Grade;
    var_dump($this->request->getQuery());//result: array(1) { ["_url"]=> string(40) "/api/v1/user/0cafdf577605/grades/1/apply" }
    var_dump($this->request->get());//result: array(1) { ["_url"]=> string(40) "/api/v1/user/0cafdf577605/grades/1/apply" }
    var_dump($this->request->getPost());//result: array(0) { }

I want to get the value of the classId .What should I do?

edited May '17

In handler method/function just add $uuid and $classId as parameters/arguments.

Not sure if parameter in prefix will work. You can possibly access them using $this->router->getParams(). But better just add them as argument to function/method.