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.

Generating urls for \Phalcon\Mvc\Micro\Collection

I'm looking for a solution that will allow me to generate urls using Phalcon\Mvc\Url for \Phalcon\Mvc\Micro\Collection (using a controller as a handler).

This is my collection setup

$app = new \Phalcon\Mvc\Micro($di);  //$di contains my url service

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



$nappiCollection->get('/{id:[0-9]+}', 'show');


I basically want to be able to do this:

     $nappiCollection->get('/{id:[0-9]+}', 'show')->setName('show-nappi')

and then generate a url like this:

        'for' => 'show-nappi',

unfortunately \Phalcon\Mvc\Micro\Collection does not have a setName method. How should I deal with this?


You can pass the name as third parameter:

$nappiCollection->get('/{id:[0-9]+}', 'show', 'show-nappi');

edited Nov '14

Fantastic exactly what I'm looking for! Thankyou!