Closed mgpro94 closed 11 months ago
An interesting scenario. Would require more than just conditional loading of sprinkles.json
though. At least if this functionality is to land in UF in any reliable fashion.
Off the top of my head, for this to be done we need:
public
.I think, at the very least, we should remove the hardcoded sprinkles.json
string and make it a constant defined in defines.php
.
+1
The constants can be overwritten by sprinkle defined one? But then I guess it would be loaded after that info is require. Or maybe it could it be overwrittable by the env settings?
Nothing that fancy. People who need to change the default sprinkles.json
will likely be manually instantiating UserFrosting
anyway. So, we just need to factor the default name as a constant, and add a UserFrosting::setSprinkleSchemaFile
method, or something like that.
Could even use loaders to support JSON or YAML.
It could also be changed using Bakery somehow...
i think to give the option to change the default definition by UserFrosting::setSprinkleSchemaFile
method would be the best
if you defined this by env settings or bakery this would be the same as static file name you should be able to change the file in run time
Problem is if you have to edit app/system/UserFrosting.php
, you are editing core code, which is bad. And we can't have it in a sprinkle, since it needs to be done before the sprinkles are actually loaded.
Nevertheless, your issue is different than the fact the sprinkle file is hardcoded. Having a different set of sprinkle depending of the domain is nonsense for me. If there's really a difference between the two domains, it should be handled inside a sprinkle. Even better, I would go for two different install, one for each domain, even if they have to share the same db. What is the reason you need to load a different sprinkle based on the domain name?
i made two base sprinkles of my system (one is template and another is functionality) each domain has a different land page but with the same functions and management.. only differences is settings and minor changes on template
when this will scale up with more domain.. this will be hard for me to update every host..
if i can manage with sprinkles will be loaded by domain (or any other way) in the index.php
file
(and this is before the sprinkles loaded)
this will be much more easier for me
I dont see why my example (in the post) is wrong or not good ?
I actually did originally envision a multi-tenant situation (what @mgpro94 is describing) as one possible use case for Sprinkles. In fact, I actually designed the Sprinkle system based on some "proto-sprinkles" I was using in a multi-tenant project of my own, where each site had a separate "proto-sprinkle" in the same installation.
I ultimately ditched that approach in favor of using a common Sprinkle shared among separate installations of UF, but I don't think @mgpro94's use case is so far-fetched.
Actually, this could also be resolve and/or be in conflict with #747 & #728.
This is now possible with UF5. Simply create two Recipe, and load the correct one in index/bakery.
@alexweissman Follow the conversation here: https://forums.userfrosting.com/t/can-i-load-different-sprinkle-for-each-domain/97
we agreed to add a way to load custom "sprinkles.json"..
as i suggested:
file: public/index.php
file: app/system/UserFrosting.php