[英]How to include a codeigniter project into another php file?
I have a project based on codeigniter. 我有一个基于codeigniter的项目。 And I should use one class that extended from a codeigniter controller in another php file.
我应该使用从另一个PHP文件中的codeigniter控制器扩展的类。 But I didn't find the solution about how to teach another php file to see whole CI-project.
但是我没有找到有关如何教另一个php文件查看整个CI项目的解决方案。 Beyond that needed class can not inherit when i call it from other place.
当我从其他地方调用它时,超出该需要的类不能继承。
I'm not 100% sure if this helps get you in the right direction, but kudos if it does! 我不确定这是否能帮助您朝正确的方向发展,但不是100%肯定,但是如果能成功,则应该赞誉!
Codeigniter routes the application depending on the environment state of the URI. Codeigniter根据URI的环境状态来路由应用程序。 What you need to do is set the environment and include the index view file like so:
您需要做的是设置环境并包括索引视图文件,如下所示:
$_SERVER["REQUEST_URI"] = "cms/2";
//Set GET action,method params etc
require_once "path/to/index.php";
When you load CI Index file it reads the SERVER Variable and others which you may have to find and execute the controller and method, I would also advise that you modify the library/view file as it may exit upon output causing your script to exit. 当您加载CI索引文件时,它会读取SERVER变量以及可能需要查找并执行控制器和方法的其他变量,我也建议您修改库/视图文件,因为它可能在输出时退出并导致脚本退出。
Also you may wis hto look into ob_start() to catch the buffer. 另外,您可能还希望观察ob_start()以捕获缓冲区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.