We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

how can i make /home/ as my /index/

how can i make /home/ as my /index/ so that upon my website loads instead of /index/ it will trigger /home automatically?



98.9k

You can use:

$router->setDefaultController('home');

In your router

https://api.phalcon.io/en/1.3.3/Phalcon/Mvc/Router#setDefaultController-details

edited Oct '14

still not working here is my code

$router = new Phalcon\Mvc\Router();
$router->setDefaultController(
    array(
        "controller" => "home",
        "action"     => "index"
    )
);
$router->handle();

i created a folder named router in my app folder and in my config.php i add 'routerDir' => DIR . '/../../app/router/',

also in my loader.php i add $config->application->routerDir,

am i missing somthing coz i still get IndexController handler class cannot be loaded on my screen



98.9k

It does not work like that, it must be:

$router = new Phalcon\Mvc\Router();
$router->setDefaultController("home");
return $router;