gpt4 book ai didi

php - 在 codeigniter 中使用 hmvc 时未加载 routes.php 文件?

转载 作者:搜寻专家 更新时间:2023-10-31 21:39:54 24 4
gpt4 key购买 nike

我有 hmvc 设置并且工作正常,

我有一个图库模块。

图库模块分为三个 Controller ,其结构如下:

/modules/gallery/
/modules/gallery/config/
/modules/gallery/helpers/
/modules/gallery/controllers/
/modules/gallery/controllers/gallery.php
/modules/gallery/controllers/galleries.php
/modules/gallery/controllers/images.php
/modules/gallery/models/
/modules/gallery/models/galleriesmodel.php
/modules/gallery/models/imagesmodel.php
/modules/gallery/views/dashboard.tpl
/modules/gallery/views/galleries/dashboard.tpl
/modules/gallery/views/images/dashboard.tpl

无论如何,我的 images.php Controller 中有一个名为 list_items 的函数

所以我要映射url
http://example.com/gallery/images/list
http://example.com/gallery/images/list_items

所以我想,甜蜜的,我将只添加一个 /modules/gallery/config/routes.php,其中包含路由。

但是好像没有包含路由。

包含来自 /application/config/routes.php 的路由,如果我在模块 routes.php 中放置一个 die('loaded') 它确实杀死了脚本,

但是正在运行

来自其中一个 Controller 的

print_r($this->router) 没有显示来自模块 routes.php 的任何路由。

这是怎么回事?

最佳答案

据我所知,

HMVC 仅在每个模块内查找请求的 Controller ,具有不同的层次结构模型,但永远不会读取模块内使用 routes.php 的路由覆盖。

查看 MX_Router::locate 它从不在任何模块中查找 routes.php

它也不会覆盖在配置文件夹中查找 routes.phpCI_Router::_set_routing

您将必须覆盖 CI_Router::_set_routing 并阅读每个可用模块中的 config/router.php 以使您的模块路由覆盖正常工作。

关于php - 在 codeigniter 中使用 hmvc 时未加载 routes.php 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12446377/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com