如何设置 Codeigniter 来处理具有共享 ci 库的多个项目?
我见过几个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个应用程序(“dataentry”和“cpanel”)是否都有自己的主index.php 文件,该文件定义了适当的$application_folder 变量?
另外 - 我确信您已经阅读过文档 - 但 CodeIgniter 的文档指出/applications 目录(或多个目录,在您的情况下)应存在于 /system 目录下,如下所示:
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:
好的 - 我已经按预期工作了。我将尝试编写更广泛的“操作方法”,并在评论部分提供链接。
我不需要修改 .htaccess 超过 CI 的要求 - 我对此很高兴。我的入口目录如下所示:
/dd/index.php
两个关键部分在这里:
这允许单个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:
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.)