[Coldbox 4.x] - External Models?

Hi,

I have two separate coldbox applications that I want to be able to share the same models. I created another subfolder outside of both of these coldbox applications called “Shared_Models” for example. I dropped one of my CFCs in there and created a CF mapping on the server that points to this new directory. I updated my Wirebox.cfc file in one of the Coldbox apps with this small snippet:

// Map Bindings below
mapDirectory(‘Shared_Models’);

I then tried to run my app and I’m getting an error because I have some property declarations at the top of my CFC that inject some settings from my main Coldbox.cfc file

property name=“siteURL” inject=“coldbox:setting:siteURL”;

Now that I’ve moved this CFC outside of the coldbox app it broke some of these injections. Is there another way I should be doing this?

my site has a front-end and a backend, and each are two separate coldbox apps that I’m finding need to share more model layer code than originally anticipated.

Any help or guidance here would be great.

Thanks!

Can you just add that setting to both apps? If both apps need that CFC and that CFC needs that setting, it seems logical that both apps should have the setting.

If you’re not wanting to have that config in two places, there’s a host of ways you can define some shared configuration that both apps use.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Yes, I can do that, and that’s how it is, I think I phrased my question wrong.

I’m struggling with being able to access the CFC from both apps. As a result of me moving the CFC outside of both ColdBox apps it broke that setting as a result. So I have this folder structure

/wwwroot/siteA
/wwwroot/siteB
/wwwroot/coldbox
/wwwroot/shared_models

And then I have the CFC I’m trying to share in the “shared_models” folder. I’m trying to access the CFC in this location so I’m not updating code in the same CFC for two different apps.

Sorry, I guess I’m just a little confused. Do you still have a question or is it answered now?

> I’m struggling with being able to access the CFC from both apps.

It sounds like you’re “accessing” the CFC just fine-- it was just erroring during its creation based on the dependencies required to build it.

> As a result of me moving the CFC outside of both ColdBox apps

The location on the hard drive doesn’t really matter. A model isn’t really “inside” or “outside” an app. WireBox simply knows about it or it doesn’t.

> it broke that setting as a result.

How do you “break” a setting? If your CFC requires that setting to exist in the applications that build it, then it’s just a requirement that both apps will have the setting right? Am I missing something?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Nope, thanks that helped… appreciated!