简体   繁体   English

是否有codeigniter控制器子目录限制?

[英]Are there codeigniter controller sub-directory limits?

Greetings, 问候,

I've encountered a seemingly bizarre issue, and was wondering if anyone is able to shed a light. 我遇到了一个看似奇怪的问题,并且想知道是否有人能够解决问题。

I created a simple controller two levels down from the traditional /application/controllers/ directory and I'm seeing a CI-generated 404 when hitting said controller. 我创建了一个简单的控制器,从传统的/ application / controllers /目录下来两级,我在看到控制器时看到了CI生成的404。

To elaborate, my directory structure is as follows: /ci/application/controllers/dir1/dir2/myfile.php 详细说明,我的目录结构如下: /ci/application/controllers/dir1/dir2/myfile.php

The file itself has a simple function with an echo statement. 该文件本身具有一个带有echo语句的简单函数。 When I move said file up one level such that it is located in: /ci/application/controllers/dir1/myfile.php 当我将所述文件向上移动一级时,它位于: /ci/application/controllers/dir1/myfile.php

It works. 有用。

I've tried changing the name of the "dir2" directory in the example above, the name of the controller, the names of the functions within the controller -- to no avail. 我已经尝试在上面的例子中更改“dir2”目录的名称,控制器的名称,控制器内的功能名称 - 无济于事。 I'm able to hit the same php file without going through the Code Igniter framework, and I'm on a Windows machine working normally so I can't imagine this to be a permissions-related issue. 我能够在不通过Code Igniter框架的情况下点击相同的php文件,而且我在Windows机器上正常工作,所以我无法想象这是一个与权限相关的问题。

I'm led to think that CI simply isn't willing to go into the controllers directory more than one level. 我认为CI根本不愿意进入控制器目录多个级别。 Is this possible, or am I missing something? 这可能,或者我错过了什么?

Try this out: http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/ 试试这个: http//glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/

Basically, you need to override the default codeigniter router with your own MY_Router class 基本上,您需要使用自己的MY_Router类覆盖默认的codeigniter路由器

"Out of the box", Codeigniter only supports a single level directory structure for Controllers. “开箱即用”,Codeigniter仅支持控制器的单级目录结构。

There are ways to extend the default Router class to enable this feature. 有一些方法可以扩展默认的Router类以启用此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM