Routing in micro collection

Hi... I'm new in phalcon and try to make a simple api using phalcon micro and micro collection. I'm try to make a route which can be access through POST and GET method. this is a piece of code i'm using

$myMicroCollectionObj = new \Phalcon\Mvc\Micro\Collection();

$myMicroCollectionObj->setHandler("\Controllers\TestController",true);

$testMicro->setPrefix("/test");

$myMicroCollectionObj->map("/actionpostget","actionpostget")->via(['POST','GET']);

and i get this error message :

Uncaught Error: Call to undefined method Phalcon\Mvc\Micro\Collection::via()

Thanks



1.1k

The "via" option is a config only for "micro" class, not his childrens...

You can alternate this doing:`

$myMicroCollectionObj->put(...);
//or
$myMicroCollectionObj->get(...);

Here some example used in this forum:

https://github.com/cmoore4/phalcon-rest/blob/develop/routes/collections/example.php

edited Dec '16

via() method does not exist in MicroCollection. Simple as that.

class Collection implements \Phalcon\Mvc\Micro\CollectionInterface

https://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Micro_Collection.html