Getting started with CommandBox server instances
Adobe ColdFusion has been around for a long time. Originally released in 1995, ColdFusion made it easy to connect a web page to a database backend. Now we even have open-source ColdFusion application servers such as Lucee that has made it easier than ever before to get in to CF development. Unfortunately, the ColdFusion tool chain can feel like it is still back in 1995 compared to other languages.
While both Adobe ColdFusion and Lucee offer express installers, I would rather spend less time configuring the application server and more time developing. It seems the guys at Ortus Solutions feel the same way with the release of CommandBox in 2014.
There is no way I could cover all the features provided by CommandBox. It is very well documented, I would definitely recommend checking it out. It can handle package management as well as quickly scaffold a ColdBox application. The feature I will be focusing on, however, is the ability to quickly spin up an ad hoc, light-weight ColdFusion/Lucee development server in any directory from the command line.
Installation on MacOS is easily done with Homebrew by issuing the following command in a terminal:
brew install commandbox.
Download the executable from the CommandBox site. Extract the file contents to a folder on your machine and ensure this folder is in your system
PATH environment variable so it will be available to any terminal window. The process is explained in detail here. I generally install to C:\CommandBox to keep things consistent and easy to find.
Creating your first instance
Once installed the hardest part is done. I will run through a very quick example just to show you how easy it is. I created the commandbox directory in my skunkworks projects. Inside the directory, I will create an index.cfm file and launch the server with Adobe ColdFusion 2016.
# rob @ MacBook-Pro in ~/area51/commandbox [18:29:59] C:1
$ echo '<cfdump var="#CGI#" />' > index.cfm
$ box start cfengine=adobe@2016
Contacting ForgeBox to determine the latest & greatest version of [adobe 2016]... Use an exact 'cfengine' version to skip this check.
OK, [adobe 2016.0.05+303689] it is!
Installing package [forgebox:adobe@2016]
Verifying package 'adobe' in ForgeBox, please wait...
Installing version [2016.0.05+303689].
Verified entry in ForgeBox: 'adobe'
Package found in local artifacts!
Installing to: /Users/rob/.CommandBox/temp/ECA1E34B-C4E1-4AB5-9949A9FCFFCC62E3
-> 2 File(s) Installed
-> 0 File(s) ignored
Eureka, 'adobe@2016' has been installed!
Exploding WAR/zip archive...
The server for /Users/rob/area51/commandbox/ is starting on http://127.0.0.1:56798 ...
Starting in background - Server is up - http-port:56798 stop-port:56799 PID:5220
That is all there is to it. You can also try
box start cfengine=lucee@5 to see how your application will perform running on Lucee.
Wrapping it all up
The purpose of this article was to cover one aspect of CommandBox. If it did nothing else it would still be worth installing just for removing the hassle of server configuration. CommandBox also has some useful plugins such as cfconfig to make it easy to import/export server settings.