CFConfig

Background

CFConfig is a CommandBox module which allows most if not all of the CF / BoxLang settings for a server to be set via a JSON file rather than using the CFAdministrator. This makes it much easier to scaffold servers in various situations such as:

  • Keeping development environments up to date

  • Production servers with their own passwords / mappings / data sources etc

  • Development Environment

  • Containers

Some Examples

Mappings

  1. Create a folder outside of the root folder called JEMapps

  2. In JEMapps, create a text file called outsideroot.txt and put some text into it.

  3. From CommandBox, install install commandbox-cfconfig

  4. From CommandBox, from the root of the site, type cfconfig cfmapping save virtual=/JEMapps physical=path\to\JEMapps to=.cfconfig.json

  5. Type cat .cfconfig.json

  6. Restart your server with server restart

  7. In your index.cfm file, add:

    <cfdirectory directory="#expandpath('/JEMapps')#" name="listing" />
    <cfdump var="#listing#" />
    <cffile action="read" file="#expandpath('/JEMapps/outsideroot.txt')#" variable="read" />
    <cfdump var="#read#" />

Datasources

From CommandBox, from the root of the site, type

cfconfig datasource save database=DATABASENAME dbdriver=mysql host=justenough.cyqisqc1fx3i.us-west-2.rds.amazonaws.com username=USERNAME password=PASSWORD port=3306 name=justEnough class=com.mysql.cj.jdbc.Driver to=.cfconfig.json

Restart the server ( server restart ). We're going to investigate that datasource more very soon but for now if there are no errors, the datasource is set up correctly.

Last updated