Right, so a couple things-- people don’t normally put system modules that install into CommandBox in their box.json of a specific project. Technically, when you install CFConfig, it does get stored in a box.json somewhere, but it’s an internal one to commandbox. That said-- if you want other people to be able to clone your repo, run “box install” and have everything they need, that will work. However, I’d recommend putting it as a dev dependency.
CFConfig will automatically load the file if it’s called exactly “.cfconfig.json” and it’s in your webroot. Or you can customize the name in your server.json file. Check the docs for all the specifics on this:
https://cfconfig.ortusbooks.com/using-the-cli/commandbox-server-interceptors/server-start
So the webroot question is a bit trickier. To be honest, I would recommend you not store these mappings at all in the server level and just use your Application.cfc’s this.mappings since that gives you a lot of control over dynamically setting up your mappings.
CF mappings in your cfconfig JSON are just used as-is and not made absolute or anything. You can use placeholders in your JSON such as ${myEnvVar} but CommandBox doesn’t currently set anything automatically when starting a server. I’ve had it in mind to do something like that for a while but never quite decided on what it should set and when. What you can do is add in the commandbox-dotenv module to your mix and introduce a .env file with a variable that you set to whatever your web root will be. So your .env might look like
mywebroot=/Users/fusionkanna/Documents/projects/bindi/
Then your config json would have something like
“PHYSICAL”:"${mywebroot}faww"
But that’s not really a super good solution because it still requires each dev to create and maintain the .env file. If you want to get fancier (and you’re on the latest version of CommandBox) you could add some magic sauce of your own. If you put something like this in your box.json
“scripts”:{
“preServerStart” : “env set myWebRoot=pwd
”
}
Then that would set a dynamic environment variable that only lives for the life of the start command called “mywebroot” equal to the output of pwd (print working directory). Then you could pick that up with ${mywebroot} in your cfconfig JSON file. Note, the above assumes you actually run the start command from the web root. Running “start myservername” from elsewhere would have an incorrect web root since the working directory of the shell would be elsewhere which you could work around by swapping “pwd” with something like
server info name=myServerName property=webroot
Lots of ways to skin the cat. Hopefully that gives you some idea, but seriously, i would avoid putting this in CFConfig specifically just because application.cfc makes it so easy. You can still use CFConfig for other stuff though 