Accessing request parameters in controller using request object

Hi guys:

I am a newbie to the beautiful world of Phalcon, and have got stuck for almost a long time. My question is as follows: The following code snippet works like a charm: public function someAction($age) { // Do things with $age } However, I wonder how I can do it without using formal parameters but instead using $this->request->getPost('age') for example. When doing this, I get NULL ($GET and $POST are also NULL). Should I define a new Routing/Dispatching scheme for this to happen? Why $GET (and/or $POST) array is not populated correctly in this case and only contains:

array(1) { ["_url"]=> string(16) "/person/some/age/2" }

class PersonController extends Phalcon\Mvc\Controller { public function someAction() { // $this->request->getPost('age'), $this->request->getQuery('age'), $GET, and $POST are all NULL here } } Access URL I used to test: http://localhost/myapp/person/some/age/40



84.5k

This ?age=2 will populate $GET, Using method="post" in your form will populate $POST

You can get the parameters making them work as you want: http://docs.phalconphp.com/en/latest/reference/dispatching.html#preparing-parameters

Thanks a lot dude...Keep up the good work! Viva Phalcon and its awesome team!