How to use Codeigniter with other framework? |
I would like to use the database classes and methods in other PHP frameworks. I have an idea if I include the autolader from vendor it will work, but I can't find a tutorial about that. Could anyone please help me?
I think you need to choose a framework. They are not generally designed to inter-operate.
I chose to move from Laravel because I was not using many of the included features and it appears slow to my clients. I ended up choosing Codeigniter due to its light weight and speed. For my needs, we really need to move a longer term supported release including patches but without breaking changes. The current reading changes and file changes can be daunting, especially if your enterprise project is several releases behind, (04-22-2024, 02:39 PM)kenjis Wrote: This might be helpful. It is still not enough. I am trying to get inside autoload vendor.
1. Install "codeigniter4/framework" via Composer.
2. add dependencies (constants, functions, etc.) in somewhere when needed. (04-24-2024, 03:44 PM)kenjis Wrote: 1. Install "codeigniter4/framework" via Composer. Let me try another time. Suppose you want to use CI4 in another framework that does not support composer autoloader. I am a noob at this. But I can understand that there are class path that I can use. But I don't know the class names or the namespaces. Have you heard of Eloquent from Laravel. We can use this independently anywhere.
All you have to do is:
1. Before using a class or function, load the class or function definition. 2. Before using a constant, define the constant. So this is not difficult (but may be bothersome) if you know how to use PHP. CI4 follows PSR-4, so if you have or write a PSR-4 autoloader, it can autoload class files. CI4 uses namespace "CodeIginter". See https://github.com/codeigniter4/CodeIgni...on#L63-L65 If there is something missing to load/define, PHP raises an error. So you just the load/define missing things. |
Welcome Guest, Not a member yet? Register Sign In |