CodeIgniter Forums
Multiple application with CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Multiple application with CI4 (/thread-71366.html)



Multiple application with CI4 - Przem4S - 08-06-2018

Hi,

How to create multiple application with CI4?
Example, other application for admin's and clients.
How to resolve this?
How to execute first and second?

Thanks for help.


RE: Multiple application with CI4 - John_Betong - 08-06-2018

I have a menu of available applications and use a PHP session to remember the current application.

All applications use the same ../CodeIgniter4/system folder.

Check out my signature,


RE: Multiple application with CI4 - Przem4S - 08-06-2018

Yeah that is good idea, now I switch by get parameter, but saving this to session is much pretty solution.
I think about 'old' solution: segment in url like /admin but with latest CI4 that's not work property (admin segment set as controller).
I need structure multi-applicational like /applications/one1 (inside all Config/Controllers/Filters/Language/Models etc.) and second /applications/one2 (inside all Config/Controllers/Filters/Language/Models etc.) and maybe in future more apps.


RE: Multiple application with CI4 - John_Betong - 08-06-2018

I do not understand your requirements.

As mentioned I used multiple application copies like app_one, app_two, app_three, etc.

Also each application shares common files saved in the "writable" folder.


RE: Multiple application with CI4 - kilishan - 08-06-2018

(08-06-2018, 05:42 AM)Przem4S Wrote: I think about 'old' solution: segment in url like /admin but with latest CI4 that's not work property (admin segment set as controller).

Why wouldn't this work currently? It still supports automatically determining controller based on URL so should work just like CI3 did in that respect. Additionally, you can use Route groups to add a prefix to other controllers, if you're specifying all of your routes in the routes file.

(08-06-2018, 05:42 AM)Przem4S Wrote: I need structure multi-applicational like /applications/one1 (inside all Config/Controllers/Filters/Language/Models etc.) and second /applications/one2 (inside all Config/Controllers/Filters/Language/Models etc.) and maybe in future more apps.

Fairly easily done: make multiple copies of the application folder, and rename to whatever apps you have:

Code:
admin/
        Controllers/
        Models/
        etc
    clients/
        Controllers/
        Models/
        etc
    public/
        admin/
            index.php
        clients/
            index.php
    system

This is the safest way to do it, though you could make each a "flat" structure by bringing the public folder along with it.

In the Config\Paths.php file for both applications, adjust to make sure they point to the appropriate directory and the shared system directory.

Either this solution, or the one I mentioned at the top of this post work. If you want to share models, that's pretty easily done by ensuring they are namespaced and both applications know where to find them. Or, just use the route groups, mentioned above, and keep them all in a single application so models, libraries, etc don't need to be duplicated.

Lots of options. Smile