Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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 Zend路由,未找到抛出资源_Php_Zend Framework_Routing - Fatal编程技术网

Php Zend路由,未找到抛出资源

Php Zend路由,未找到抛出资源,php,zend-framework,routing,Php,Zend Framework,Routing,我有一个网址:http://dev.local/foodies/view?id=bluedaniel 我在我的引导程序中: protected function _initRoute() { $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production'); $router = new Zend_Controller_Router_Rewrite();

我有一个网址:
http://dev.local/foodies/view?id=bluedaniel

我在我的引导程序中:

protected function _initRoute() {
        $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
        $router = new Zend_Controller_Router_Rewrite();
        $router->addConfig($config, 'resources');
    }
protected function _initRoutes() {
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $router->addRoute('userprofile', new Zend_Controller_Router_Route('user/:id/', array('module' => 'foodies', 'controller' => 'view', 'action' => 'index', 'id'=>'\w+')));
}
及 我也加入了我的路线。ini:

[production]
resources.router.routes.foodies_view.route = ":foodies/:id"
resources.router.routes.foodies_view.defaults.module = "foodies"
resources.router.routes.foodies_view.defaults.controller = "view"
resources.router.routes.foodies_view.defaults.action = "index"
那么,这应该是正确的吗

我得到一个资源“foodies:bluedaniel”未找到错误,但是使用此设置

--------------更新------------------

我在application.ini文件中添加了以下内容,而不是上述内容:

resources.router.routes.myroute.route = "foodies/:id"
resources.router.routes.myroute.defaults.module = "foodies"
resources.router.routes.myroute.defaults.controller = "view"
resources.router.routes.myroute.defaults.action = "index"
resources.router.routes.myroute.defaults.id = "\w+"

这个方法现在可以工作了,尽管如果我能帮忙的话,我还是希望路由在它们各自的ini文件中。

如果有人感兴趣,我已经解决了这个问题,现在在我的引导中:

protected function _initRoute() {
        $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
        $router = new Zend_Controller_Router_Rewrite();
        $router->addConfig($config, 'resources');
    }
protected function _initRoutes() {
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $router->addRoute('userprofile', new Zend_Controller_Router_Route('user/:id/', array('module' => 'foodies', 'controller' => 'view', 'action' => 'index', 'id'=>'\w+')));
}
问题是,在我的navigation.xml中,我需要向每个节点添加
default
。Zend文档有时确实非常糟糕


我还需要为id声明一个默认变量,否则它将无法识别传递的id。

如果有人感兴趣,我已经解决了这个问题,现在在我的引导中:

protected function _initRoute() {
        $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', 'production');
        $router = new Zend_Controller_Router_Rewrite();
        $router->addConfig($config, 'resources');
    }
protected function _initRoutes() {
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $router->addRoute('userprofile', new Zend_Controller_Router_Route('user/:id/', array('module' => 'foodies', 'controller' => 'view', 'action' => 'index', 'id'=>'\w+')));
}
问题是,在我的navigation.xml中,我需要向每个节点添加
default
。Zend文档有时确实非常糟糕


我还需要为id声明一个默认变量,否则它将无法识别传递的id。

事实上,使用此更新的方法,zend_导航中的链接现在显示为/foodies。非常奇怪的是,使用这个更新的方法,现在zend_导航中的链接显示为/foodies。非常奇怪,然后在视图助手$this->url(数组('module'=>'foodies','controller'=>'view'),'userprofile');以所需格式创建url。然后在视图帮助程序$this->url(数组('module'=>'foodies','controller'=>'view'),'userprofile');以所需格式创建url。