Php 要更改默认路由吗
我想更改Php 要更改默认路由吗,php,phalcon,phalcon-routing,Php,Phalcon,Phalcon Routing,我想更改phalcon中的默认路由,这是indexcontroller的索引操作 Myroutes.php: $router = new \Phalcon\Mvc\Router(); //Define a route $router->add( "/", array( "controller" => "admin", //previously it was "index" "action" => "index",
phalcon
中的默认路由,这是indexcontroller
的索引操作
Myroutes.php
:
$router = new \Phalcon\Mvc\Router();
//Define a route
$router->add(
"/",
array(
"controller" => "admin", //previously it was "index"
"action" => "index",
)
);
$router->handle();
现在当我打开我的网站(例如http://localhost/test/
)在浏览器中,它会给我错误信息:
IndexController handler class cannot be loaded
#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('IndexController...', 2)
#1 [internal function]: Phalcon\Dispatcher->dispatch()
#2 C:\wamp\www\test\public\index.php(36): Phalcon\Mvc\Application->handle()
#3 {main}
我不明白为什么我的路线在路线文件中被替换后仍会进入
indexcontroller
?要设置您需要使用的默认控制器-
$router->setDefaults(array(
'controller' => 'admin',
'action' => 'index'
));
也许很傻,但是你复制了你的文件而没有更改类名吗?不,不是这样的。哇,它起作用了。你救了我一天。但我在以前的项目中从未写过这一行,它仍然可以正常工作。