Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 要更改默认路由吗_Php_Phalcon_Phalcon Routing - Fatal编程技术网

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
的索引操作

My
routes.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'  
));

也许很傻,但是你复制了你的文件而没有更改类名吗?不,不是这样的。哇,它起作用了。你救了我一天。但我在以前的项目中从未写过这一行,它仍然可以正常工作。