php – ZF2查看url helper忽略控制器和动作
发布时间:2020-12-13 22:46:51 所属栏目:PHP教程 来源:网络整理
导读:模块/的applcation /配置/ module.config.php 'router' = array( 'routes' = array( 'home' = array( 'type' = 'ZendMvcRouterHttpLiteral','options' = array( 'route' = '/','defaults' = array( 'controller' = 'ApplicationControllerIndex','acti
模块/的applcation /配置/ module.config.php
'router' => array( 'routes' => array( 'home' => array( 'type' => 'ZendMvcRouterHttpLiteral','options' => array( 'route' => '/','defaults' => array( 'controller' => 'ApplicationControllerIndex','action' => 'index',),'application' => array( 'type' => 'Segment','options' => array( 'route' => '/application[/:action][/]','defaults' => array( '__NAMESPACE__' => 'ApplicationController','controller' => 'Index','action' => 'index','may_terminate' => true, 在我的IndexController.php中,我有一个indexAction()和validateAction() – (只是试验他们真的没有函数) 我可以很好地了解意见.但我在视图中写道: echo $this->url('application',array('action' => 'validate')); 它只是回声 /application/ 我怎样才能让它回应行动的路径?我已经尝试了我能想到的一切,并且找不到任何合理的文档,或者其他任何有同样问题的人. 这是配置页面加载时的var_dump: array(5) { ["router"]=> array(1) { ["routes"]=> array(2) { ["home"]=> array(2) { ["type"]=> string(28) "ZendMvcRouterHttpLiteral" ["options"]=> array(2) { ["route"]=> string(1) "/" ["defaults"]=> array(2) { ["controller"]=> string(28) "ApplicationControllerIndex" ["action"]=> string(5) "index" } } } ["application"]=> array(2) { ["type"]=> string(7) "segment" ["options"]=> array(2) { ["route"]=> string(25) "/application[/:action][/]" ["defaults"]=> array(3) { ["__NAMESPACE__"]=> string(22) "ApplicationController" ["controller"]=> string(5) "Index" ["action"]=> string(5) "index" } } } } } ["service_manager"]=> array(1) { ["factories"]=> array(1) { ["translator"]=> string(45) "ZendI18nTranslatorTranslatorServiceFactory" } } ["translator"]=> array(2) { ["locale"]=> string(5) "en_US" ["translation_file_patterns"]=> array(1) { [0]=> array(3) { ["type"]=> string(7) "gettext" ["base_dir"]=> string(57) "/home/marshall/html/module/Application/config/../language" ["pattern"]=> string(5) "%s.mo" } } } ["controllers"]=> array(1) { ["invokables"]=> array(1) { ["ApplicationControllerIndex"]=> string(38) "ApplicationControllerIndexController" } } ["view_manager"]=> array(7) { ["display_not_found_reason"]=> bool(true) ["display_exceptions"]=> bool(true) ["doctype"]=> string(5) "HTML5" ["not_found_template"]=> string(9) "error/404" ["exception_template"]=> string(11) "error/index" ["template_map"]=> array(4) { ["layout/layout"]=> string(73) "/home/marshall/html/module/Application/config/../view/layout/layout.phtml" ["application/index/index"]=> string(83) "/home/marshall/html/module/Application/config/../view/application/index/index.phtml" ["error/404"]=> string(69) "/home/marshall/html/module/Application/config/../view/error/404.phtml" ["error/index"]=> string(71) "/home/marshall/html/module/Application/config/../view/error/index.phtml" } ["template_path_stack"]=> array(1) { [0]=> string(53) "/home/marshall/html/module/Application/config/../view" } } } 解决方法
如果您从
ZendSkeletonApplication开始,是否已从应用程序模块的配置中删除了
pre-defined ‘application’ route?我可以在最新的ZendSkeletonApplication中复制它的唯一方法是在已经定义的路由之前定义应用程序路由.
例如,module.config.php中的这个路由部分适合我: 'router' => array( 'routes' => array( 'home' => array( 'type' => 'ZendMvcRouterHttpLiteral','application' => array( 'type' => 'segment',) 使用它,它的工作原理: <?= $this->url('application',array('action' => 'validate')) ?> // Produces /application/validate/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |