I extended the default Phalcon Router with a new way to mount groups. This enables me to mount groups using a different kind of syntax. It has the function below:
public function group($prefix = null, $routes) {
$group = new RouterGroup();
if ($prefix != null) {
if (strpos($prefix, '/') == false) {
$prefix = '/'.$prefix;
}
$group->setPrefix($prefix);
}
$routes($group);
$this->mount($group);
return $group;
}
Using this, I can add a new route group like this:
$router = new Router();
$router->removeExtraSlashes(true);
$router->group("api", function ($group) {
});
On my local machine, running Phalcon 3.2 on PHP 5.6.3, this works perfectly. However, on a server, running Phalcon 3.2 on PHP 7, it doesn't. It started throwing an error. Warning: Second argument is not an array in Router.php on line 48
. That's an error in $this->mount($group);
. Any ideas as to what could be going wrong?