Welcome Guest, Not a member yet? Register   Sign In
Best Practice - Shared Application Code > Multiple Front Ends
#1

I am working on a project with the idea that all of the code is the same but only the configuration details are different.
Problem: I only want one copy of CI and the code on the server.
So far I have set up:
/home/repo < the CI & Code
/home/client1/public < client front end #1
/home/client2/public < client front end #1
etc
Clients #1 and #2 have different URL's, paths and databases
I am looking for guidance as to the best way to swap out the stuff I need. I don't think I can do it in the .env file as that is in the application directory and hence shared.
I can edit index.php and add some constants that get consumed later in the code (eg: Database credentials, $baseURL, etc) but that also seems a bit counter intuative.
Is there a better way of doing this that injecting my constants at the top of index.php? Surely someone else has done it? Since all the clients use excatally the same code it would be redundant to have identical repos set up for each one?
Your help is appreciated. Thanks
Reply
#2

See https://codeigniter.com/user_guide/gener...stallation
Reply
#3

(12-01-2021, 12:22 AM)Thanks kenjis Wrote: but:

"...This would have two apps, “foo” and “bar”, both having standard application directories and a public folder, and sharing a common codeigniter framework..."

In my set up there is one app/one framework but 2 or more front ends having their own database and other settings but all sharing the same app/framework. Does that make sense? That is the problem I'm trying to solve.

Thanks
Reply
#4

I suggest Symbolic Links for the app and vendor directories then these folders can be in a central location and usable by all sites but you can still use a unique .env file for each site, that lives in the root of the site.
Reply
#5

You have two configs. It means you have two apps.
But you have only one app code.

As rich8374 suggests, use symbolic link and share app folder?
Reply
#6

Thanks for the feedback. I guess a symlink is the only clean option (not messing with CI) for now. It seems a shame because injecting a few constants at the start would solve things but no doubt be over written in future versions of CI ~ I guess that I could just sym link those files.

(Leaving open for now to see if someone else has any ideas)
Reply
#7

(This post was last modified: 12-02-2021, 07:11 PM by John_Betong.)

(12-02-2021, 03:56 PM)Webgen Wrote: Thanks for the feedback. I guess a symlink is the only clean option (not messing with CI) for now. It seems a shame because injecting a few constants at the start would solve things but no doubt be over written in future versions of CI ~ I guess that I could just sym link those files.

(Leaving open for now to see if someone else has any ideas)

I have the latest development CodeIgniter4 version “above the root” and have numerous URLs that all use the same “CodeIgniter4/system“ directory. This is achieved by changing:
PHP Code:
index.php -> $path->systemDirectory ../../CodeIgniter4/system/
Set the above variable before calling bootstrap. 

Beware that the latest development version may introduce changes which will cause every one of your CI4 installations to fail! This just happened and rectified by a small kludge.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB