Is there a way of configuring a router in Micro() not to call custom routes statically?
I have following code:
class Micro extends \Phalcon\Mvc\Micro implements IRun {
.
.
.
public function setRoutes($file) {
if (!file_exists($file)) {
throw new \Exception('Unable to load routes file');
}
$routes = include($file);
//print_r($this->getRouter());
if (!empty($routes)) {
foreach ($routes as $obj) {
$this->map($obj['route'], $obj['handler'])->via([strtoupper($obj['method'])]);
}
}
}
<routes.php>
return [[
'method' => 'get',
'route' => '/nal/v1.5/test/?{param}',
'handler' => ['Controllers\TestController', 'get']
]]
<TestController.php>
class TestController extends \Phalcon\Mvc\Controller {
public function get($val){
$r = new \stdClass();
$r->method = 'GET';
$r->value = $val;
print_r($this->di);
}
}
in <index.php>
.
.
.
$app->setRoutes($routes);
$app->run();
now when i fetch the endpoint i get following:
Strict standards: non-static method Controllers\TestController::get() should not be called statically
and
Fatal error: Using $this when not in object context