如何设置 Codeigniter 来处理具有共享 ci 库的多个项目?

发布于 2024-08-07 02:12:04 字数 1172 浏览 7 评论 0原文

我见过几个 CI 实现示例,声称您可以将项目文件夹放在 Codeigniter 的“applications”文件夹下。

然而我还没有能够看到这项工作如承诺的那样。

这是我所做的和我想做的 - 也许你可以帮忙。为了便于论证,我的文档根目录是 /www/(不是,但为了简单起见,我们使用它)

我已将 codeigniter 核心放入 /www/corelib/codeigniter

我已将 codeigniter 系统文件夹放入 /www /ci_system

我已将应用程序目录放入 /www/applications

我已将我的“入口点”放入 /www/dd

现在假设我有两个项目:“dataentry”和“cpanel” 我的

想法是我可以去h

**p://mydomain/dd/dataentry // 用于数据输入应用程序,

h**p://mydomain/dd/cpanel // 用于 cpanel 应用程序。

如果我像这样组织 dataentry 和 cpanel 目录:

/www/applications/controllers/dataentry

/www/applications/controllers/cpanel

/www/applications/models/dataentry

/www/applications/models/cpanel

/www/applications/views/ dataentry

/www/applications/views/cpanel

我可以让它正常工作。但是,我想做的是将模型和视图保持在与控制器相同的级别,以便我拥有以下内容:

/www/applications/dataentry/controllers

/www/applications/dataentry/models

/www/applications/ dataentry/views

/www/applications/cpanel/controllers

/www/applications/cpanel/models

/www/applications/cpanel/views

这似乎不起作用。

有什么建议吗?

-CF

I've seen several CI implementation examples that claim you can put project folders under the "applications" folder for Codeigniter.

However I've not been able to see this work as promised.

Here is what I have done and what I would like to do - maybe you can help out. For the sake of argument my document root is /www/(It's not, but let's use it for for simplicity's sake)

I've put the codeigniter core in /www/corelib/codeigniter

I've put the codeigniter system folder in /www/ci_system

I've put the applications directory in /www/applications

I've put my "entry point" in /www/dd

Now let's say I have two projects : "dataentry" and "cpanel"

The ideas is that I can go to

h**p://mydomain/dd/dataentry // for the dataentry application and

h**p://mydomain/dd/cpanel // for the cpanel application.

IF I organize the dataentry and cpanel directories like this:

/www/applications/controllers/dataentry

/www/applications/controllers/cpanel

/www/applications/models/dataentry

/www/applications/models/cpanel

/www/applications/views/dataentry

/www/applications/views/cpanel

I can get this to work fine. However, what I would like to do is keep the model and view at the same level as the controller so that I would have the following:

/www/applications/dataentry/controllers

/www/applications/dataentry/models

/www/applications/dataentry/views

/www/applications/cpanel/controllers

/www/applications/cpanel/models

/www/applications/cpanel/views

This does not seem to work.

Any suggestions?

-CF

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

死开点丶别碍眼 2024-08-14 02:12:04

每个应用程序(“dataentry”和“cpanel”)是否都有自己的主index.php 文件,该文件定义了适当的$application_folder 变量?

另外 - 我确信您已经阅读过文档 - 但 CodeIgniter 的文档指出/applications 目录(或多个目录,在您的情况下)应存在于 /system 目录下,如下所示:

system/application/foo/
system/application/foo/config/
system/application/foo/controllers/
system/application/foo/errors/
system/application/foo/libraries/
system/application/foo/models/
system/application/foo/views/
system/application/bar/
system/application/bar/config/
system/application/bar/controllers/
system/application/bar/errors/
system/application/bar/libraries/
system/application/bar/models/
system/application/bar/views/

Does each application ("dataentry" and "cpanel") have their own main index.php file which defines the appropriate $application_folder variable?

Also - and I'm sure you've read the docs - but CodeIgniter's documentation states that the /applications directory (or directories, in your case) should exist under the /system directory as follows:

system/application/foo/
system/application/foo/config/
system/application/foo/controllers/
system/application/foo/errors/
system/application/foo/libraries/
system/application/foo/models/
system/application/foo/views/
system/application/bar/
system/application/bar/config/
system/application/bar/controllers/
system/application/bar/errors/
system/application/bar/libraries/
system/application/bar/models/
system/application/bar/views/
老街孤人 2024-08-14 02:12:04

好的 - 我已经按预期工作了。我将尝试编写更广泛的“操作方法”,并在评论部分提供链接。

我不需要修改 .htaccess 超过 CI 的要求 - 我对此很高兴。我的入口目录如下所示:

/dd/index.php

两个关键部分在这里:

list($blank, $webpath, $app) = explode('/', $_SERVER['REQUEST_URI']);
        $application_folder = $_SERVER['DOCUMENT_ROOT]."/applications/$app";

这允许单个index.php 处理所有应用程序。

我缺少的部分是 appName 现在也必须是主控制器或者是控制器内的目录。 (我遇到的真正问题是,我进行了太多的黑客攻击,以至于我的配置和路线阻止了我意识到我实际看到的内容:有时开始清理是必要的。)

Okay - I've got this working as desired. I'll try to write up a more extensive "how-to" and will provide a link in the comments section.

I did not have to modify .htaccess anymore than CI requires - I was happy about that. My entry directory look like this:

/dd/index.php

The two key pieces are here:

list($blank, $webpath, $app) = explode('/', $_SERVER['REQUEST_URI']);
        $application_folder = $_SERVER['DOCUMENT_ROOT]."/applications/$app";

This allows a single index.php to handle all applications.

The part that I was missing is that appName must now also be the primary controller or be a directory within the controllers. (The real problem I had was that I was hacking so much that I had configurations and routes preventing me from realizing what I was actually seeing : Sometimes starting clean is imperative.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文