![]() |
require Codeigniter's public/index.php to use in existing PHP project. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: require Codeigniter's public/index.php to use in existing PHP project. (/showthread.php?tid=88699) |
require Codeigniter's public/index.php to use in existing PHP project. - aaaa - 10-20-2023 Hi, I would like to integrate an existing CodeIgniter4 Project into another existing PHP project for migration purposes. The simplest idea I could come up with was to simply include / require the public/index.php of the Codeiginiter Setup. CodeIgniter would still use its router and all services, but within another application. Let me describe my (minimized) setup: I have a standard codeigniter4 project in /webroot/codeigniter. I have a PHP file /webroot/index.php that simply requires the public/index.php with the content PHP Code: <?php Call to a member function shouldDiscover() on null /vendor/codeigniter4/framework/system/Config/BaseService.php: 37 I'm unsure how to fix this. I suspect this could be a path issue, but since we can find BaseService.php, this seems to work reasonably fine. Here are my questions: 1. What do I have to fix to make this work? 2. Is this a reasonable approach at all? Are there better ways to "integrate" a CodeIgniter Application into existing PHP infastructure? 3. Do you know of any guides how to accomplish such a task? RE: require Codeigniter's public/index.php to use in existing PHP project. - kenjis - 10-20-2023 Such integration is generally more difficult. However, your sample should work. I installed CI4 to htdocs/ci442, and I put htdocs/index.php. PHP Code: <?php I can see the "Welcome to CodeIgniter 4.4.2" page. |