I wrote dedicated converter for your needs, it should work for you any controller parameter which goes to router, for example MsCompany, MyProfile.TryThis etc without adding dedicated routes, but take care about this converter and secure it
url: https://localhost/MsCompany/index
$router->add("/:controller/:action/:params",
array(
"controller" => 1,
"action" => 2,
"params" => 3
)
)->convert('controller', function($controller) {
$new_controller = array();
for($i=0;$i<strlen($controller);$i++)
{
$lowercase = strtolower($controller[$i]);
if(ord($controller[$i])<=90 && $i>0)
{
$new_controller[]='_';
}
$new_controller[]=$lowercase;
}
return implode('',$new_controller);
});
class MsCompanyController extends \Phalcon\Mvc\Controller
{
public function indexAction()
{
$this->view->disable();
echo "Controller: ", $this->dispatcher->getControllerName();
echo "<br>";
echo "Action: ",$this->dispatcher->getActionName();
}
}
output
Controller: ms_company
Action: index