How can I do this right use Micro-routing (or maybe Phalcon\Mvc\Router)?
use Phalcon\Mvc\Micro;
use Phalcon\Loader;
$loader = new Loader();
$loader->registerNamespaces([
'App\Controllers' => __DIR__ . '/controllers/',
]);
$loader->register();
$app = new Micro();
$app->map(
'/{contollerName:[a-zA-Z0-9]+}/{actionName:[a-zA-Z0-9]+}',
function ($contollerName, $actionName) {
$c = "App\\Controllers\\{$contollerName}Controller";
$newc = new $c();
if (is_subclass_of($newc, 'Phalcon\\Mvc\\Controller')) {
if ($actionName == "show") {
echo "This is my show!";
// do smth.
}
return $newc->{$actionName}();
}
}
);
$app->handle();