In my box.json file I have the following to load t...
# box-products
g
In my box.json file I have the following to load the Ortus ORM extension.
Copy code
{
  "dependencies": {
    "D062D72F-F8A2-46F0-8CBC91325B2F067B": "^5.4.29.28"
  }
}
But when I start the server it is not in the server / Extensions / Applications. Am I doing something wrong?
b
@gavinbaumanis That's only going to work if you • run
box install
• and do it after the server has started at least once
it's not clear what you're doing and in what order however
I would recommend this instead in your
server.json
Copy code
{
  "env": {
    "LUCEE": {
      "EXTENSIONS": "D062D72F-F8A2-46F0-8CBC91325B2F067B"
    }
  }
}
g
obviously, mistangly... I thought the "install" was just for the CLI. And that the dependencies in the JSON files were unrelated.
b
Which will work automatically and on even the first server start
No, the dependencies in the
box.json
is literally what the install command installs!
g
Got it - Thanks very much!
At the moment I have a pretty much all my server config in the recipe. (I realise there is no right / wrong) But is there a better place - as a long term solution?
b
A better place for what, exactly?
Also, I'm not sure what you mean by "the recipe".
Sadly my mind reader is broken today šŸ™‚
g
Hahaha! Sorry
In the recipe file I have a cfconfig line for all the settings I want to change from the default. And I set passwords via Environment Variables in the recipe, too. so I add the install xxxx extension in there too. I am just wondering aloud if there is some sort of "best practice" That I am not following - or indeed the recipe file is the "right" place for configuring a given instance.
b
I mean, a recipe works, but using JSON files seems much simpler
Then you can just start the site with
server start
instead of having to remember to run a recipe instead.
g
but in terms of scripting a new server, then, how do I install the lex - if "just" having it in the box.json isn;t enough?
b
I personally would just • put all your CFConfig settings in a
.cfconfig.json
file in the web root (it will be loaded automatically) • put all your env vars in an
.env
file in the web root (it will also be loaded automatically)
šŸ‘šŸ¼ 1
I already told you how to get Lucee to install the lex automatically in my messages above. Use the
LUCEE_EXTENSIONS
env var. Whether you put that env var in the
server.json
like I showed, or a
.env
file, or set it in a recipe really doesn't matter.
šŸ‘šŸ¼ 1
g
Sorry Brad - I completely missed that earlier message.
b
And note, nested keys inside of the
env
object are concatenated together using undercores, so
Copy code
{
  "env": {
    "LUCEE": {
      "EXTENSIONS": "D062D72F-F8A2-46F0-8CBC91325B2F067B"
    }
  }
}
is the exact same thing as
Copy code
{
  "env": {
    "LUCEE_EXTENSIONS": "D062D72F-F8A2-46F0-8CBC91325B2F067B"
  }
}
I just like nesting them there, so if you have a number of related env vars which share a prefix, it reduces the boilerplate.
šŸ‘šŸ¼ 1
g
Thanks very much Brad
Hi Brad - sorry I think I am still doing something wrong... After restarting the server - all the additions I added to server.json for the lucee extensions in the ENV key - are cleared out. Do I still have to do a "pre" install of the extensions?
b
CommandBox does not clear anything in the server.json when starting a server.
If stuff is disappearing from there, it's something you're doing
g
box_recording.zip
I really don't want to seem argumentative, here... But you're wrong. I have the following in
sever.json
in my webroot.
Copy code
{
  "app": {
    "cfengine": "lucee@5.4.1.8"
  },
  "JVM": {
    "heapSize": "2048",
    "javaVersion": "openjdk11"
  },
  "name": "CentraCX",
  "openbrowser": "false",
  "web": {
    "http": {
      "port": "80"
    }
  },
  "server": {
    "profile": "development"
  },
  "env": {
    "LUCEE_EXTENSIONS": "testbox"
  },
  "installPaths": {
    "testbox": "../cfmapping/testbox/"
  },
  "testbox": {
    "runner": "<http://centra.localhost/tests/runner.cfm>"
  }
}
I have a
box
loaded cd \webroot server start After which the contents of the server.json file are now;
Copy code
{
  "app": {
    "cfengine": "lucee@5.4.1.8"
  },
  "JVM": {
    "heapSize": "2048",
    "javaVersion": "openjdk11"
  },
  "name": "CentraCX",
  "openbrowser": "false",
  "web": {
    "http": {
      "port": "80"
    }
  },
  "server": {
    "profile": "development"
  },
  "env": {
    "LUCEE_EXTENSIONS": "testbox"
  },
  "installPaths": {
    "testbox": "../cfmapping/testbox/"
  },
  "testbox": {
    "runner": "<http://centra.localhost/tests/runner.cfm>"
  }
}
Here is a windows "step" recording of it;
b
lol, that's invalid JSON!
You can't repeat the same key more than once. The duplicate keys are simply being discarded when the JSON is parsed.
You didn't say you had more than one extension-- supply them as a list in a single env var
Copy code
"LUCEE_EXTENSIONS":"D062D72F-F8A2-46F0-8CBC91325B2F067B,7E673D15-D87C-41A6-8B5F1956528C605F,CED6227E-0F49-6367-A68D21AACA6B07E8,17AB52DE-B300-A94B-E058BD978511E39E,etc...",
Also, what's going on here
Copy code
"LUCEE_EXTENSIONS":"testbox"
that's not a real Lucee extension ID
You seem to be confusing Lucee extensions with packages on forgebox. These are two different things
g
Great minds think alike - As I posted it - I realised the error of my ways.... And used a list instead. Hopwever I am still having issues.
b
While Lucee extensions can be listed on ForgeBox,
testbox
is not a Lucee extension
g
I have removed Testbox. - (thanks). It should be in dependencies -not extensions.
Can I set a version for an extension? I have tried with "@" and a ":" between the extension ID and the version I want to use. But neither work.
b
Copy code
LUCEE_EXTENSIONS=D46B46A9-A0E3-44E1-D972A04AC3A8DC10;version=1.0.19.19
g
Thanks very much Brad. Any chance of adding this to the CommandBox docs? I actually wasn't aware that it was "Lucee" things as opposed to to a CommandBox thing to install an extension via a environment variable. And as a result of beiong in the docs about creating settings in a server.JSON for CommnadBox - I never would have even thought to look there (in the Lucee docs). If you take suggestions... Perhaps an example of loading an extension with a version. And an example with multiple extensions? Irrespective... Thanks very much for your help - I sincerely appreciate it.
b
I don't normally document Lucee features in the CommandBox docs. I let Lucee document their own stuff šŸ™‚ That said, if you want to send a pull with a quick overview and a link to the Lucee docs, I'm not opposed.
šŸ‘šŸ¼ 1
@gavinbaumanis
g
With the realisation that you'll review / accept a PR... For me at least : It isn't so much about "Documenting a Lucee thing" - as opposed to having the knowledge available. In my mind there are two levels of experienced CFML "deveopers". • The bucket that I put myself in - "Users" • The bucket I put you / Zac / etc in... "hackers" The USER bucket - we don't spend our day developing tools / frameworks / etc where are truly intimate knowledge - across "everything" of Lucee / ACF is required. And for me at least - "service administration" - is an add-on that I have to deal with because there is no one else. So the point and click of the CFIDE / administrator - is pretty much where my admin skills start and stop. Programmatically dealing with any "admin" tasks is very new to me. (I only "just" started adding mappings and dataasources into the Application.cfc for "global" things. So while "you" inherently know that using an ENV variable to load an extension is a specifically "Lucee" thing... It is just a "thing" to me. whether it lies in the Lucee or commandBox wheelhouse (up until now) is an unknown for me. And while I was reading the CB docs - to script a recipe / .JSON file - it seemed sensible to have "Hewre is how you load an extension in a recipe file / json... here is how you specify the version. (Ofd course it makes "company" sense to have a Ortus extension in those examples. Anyway - seems I am now just rambling.... As always - thanks very much for all the help / time you always manage to find to give to me. I really appreciate it.