Micro Application Wildcard Routing

Im trying to port over a simple API from Slim and am having issues making routes that accept a variable amount of parameters. The number of parameters is unknown so I cannot hard code numerous different params. For example I have a route that can have numerous numbers of parameters:

/route/var1/var2/var3

/route/var1/var2/

/route/var7/var8/var1/var5

In Slim the syntax is:

/route/:variables+

Is there a way to do this with Phalcon micro? I noticed that the whole path is dumped into $GET['url'], however I would prefer not to have to parse that on not found. Thanks



84.0k
edited Jul '14

You can use the :params placeholder:

<?php

$app = new Phalcon\Mvc\Micro();

$app->get('/route/:params', function ($var1, $var2, $var3) {
    echo "<h1>Welcome $var1!</h1>";
});

$app->handle();

http://docs.phalconphp.com/en/latest/reference/routing.html#defining-routes