CodeIgniter Forums
Sharing things between CI4 instances - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Sharing things between CI4 instances (/showthread.php?tid=90498)



Sharing things between CI4 instances - joho - 03-27-2024

For a number of reasons, I'm toying with a "split app setup". There are basically three separate and isolated CI4 "instances" or "installations" serving the same platform. One is used for signing up/registering, one is used for logging in, and one is used once you're actually logged in.

There are obviously things these "instances" have in common, code being the most obvious item, and in some cases also data from databases.

I would like to keep them separated, but allow for "code sharing". Is there an official/recommended way of doing this, without having verbatim copies of each class, etc. in each instance of the "app"?


RE: Sharing things between CI4 instances - kenjis - 03-27-2024

If you create Composer packages, you can share the code easily.
https://codeigniter4.github.io/CodeIgniter4/extending/composer_packages.html

You don't need to publish your packages at packagist.org.
You can use private packages.


RE: Sharing things between CI4 instances - joho - 03-27-2024

(03-27-2024, 01:01 AM)kenjis Wrote: If you create Composer packages, you can share the code easily.
https://codeigniter4.github.io/CodeIgniter4/extending/composer_packages.html

You don't need to publish your packages at packagist.org.
You can use private packages.

Thank you, that's a great suggestion, and probably good practice too.

But while developing, I'd prefer a more "live" sharing setup, like a "Super Global Includes" or "Super Global Helpers"; basically so that I do not have to update composer packages for the other two "instances" when I update stuff in "the package".

I mean, in theory, this could be done by just using use/require_once/etc and then just have a "shared folder structure", but I was wondering if there was an "official way" of doing it :-)


RE: Sharing things between CI4 instances - kenjis - 03-27-2024

Do you mean that you want to have only one repository?
Then, like this:
https://codeigniter4.github.io/CodeIgniter4/general/managing_apps.html#running-multiple-applications-with-one-codeigniter-installation
and use Code Modules:
https://codeigniter4.github.io/CodeIgniter4/general/modules.html


RE: Sharing things between CI4 instances - joho - 03-27-2024

(03-27-2024, 01:30 AM)kenjis Wrote: Do you mean that you want to have only one repository?
Then, like this:
https://codeigniter4.github.io/CodeIgniter4/general/managing_apps.html#running-multiple-applications-with-one-codeigniter-installation
and use Code Modules:
https://codeigniter4.github.io/CodeIgniter4/general/modules.html

Exactly like that! I knew there would be some proper way of doing this Smile  Thank you!