Best Practice - Shared Application Code > Multiple Front Ends |
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 (12-01-2021, 12:22 AM)Thanks kenjis Wrote: but:
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.
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?
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)
(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. 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/‘; 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. |
Welcome Guest, Not a member yet? Register Sign In |