I am running multiple applications (websites) that use common CFCs between them such as for string formatting and text parsing.
I am finding it difficult having to update the same functions across multiple sites and would like to just have one library of common CFCs that any ColdFusion application can take an instance of. It would be nice if the location of the CFC library could be anywhere (on the same server or maybe on a different server or in the cloud).
Looking at documentation I am not clear if this is possible and how to do it. If not what options do we have for code resuse across applications? Can anyone point me in the right direction please?
To have a seperate folder, anywhere you want, to house common/shared CFCs all you need to do is create a mapping in your Application.cfc file and then use that to reference the CFCs and make instances of them.
In Application.cfc do the following:
<cfset this.mappings["/sharedcfc"] = "absolutepath\to\sharedfolder e.g. C:\Code\CFC" />
When you want to use a CFC in your application's code just do this:
<cfset MyCFCInstance = New sharedcfc.folder.nameofcfc() />
You can now have a common area for multi-purpose CFCs to use across your applications. What a life saver!