Loading...

PiBox

The power of CFML,
now on a Raspberry Pi



About CFML

You may have tripped across this site and you're thinking, "What is CFML?"  It is a scripting and templating language that runs on the JVM.  Raspbian conveniently comes pre-installed with Oracle Java 1.8 which makes running Java-based tools easy.  

CFML stands for ColdFusion Markup Language, but this Pi isn't running Adobe ColdFusion.  What most people don't know is that CFML has advanced considerably as a language.  It allows for a familiar scripting syntax that looks pretty similar to JavaScript in addition to it's older tag-based templating.  Modern CF devs still use the tags, but only for creating HTML views.  

Here's a snippet of CF script I wrote today.

series = fileRead('/root/stats.txt')
    .listToArray(chr(10))
    .map(function(line, index){
        return [index-1, line];
    });

In addition to modernizing, CFML also has a few open source engines out there that also run CFML, the language.  Lucee is one of these engines, and that is what is running this site.  One of the tools CF devs use is called CommandBox and it allows you to run CFML from your shell via a CLI.  It also has a nice, lightweight embedded server for spinning up websites.  

This site is running on the CommandBox embedded server.  I installed ContentBox CMS like so:

$> box install contentbox

And then started the server over SSH like so (from the web root as my current  directory):

$> box start host=192.168.1.107 --rewritesEnable --!openbrowser

This spins up the embedded server using the Tukey URL Rewrite engine, binds it to the external IP address, and tells it not to bother opening a browser window.

I can also execute ad-hoc CFML files on my Pi like so:

$> box test.cfm

As you can see, CFML is a nice language and easy to use on a Raspberry Pi.  I figured if everyone was already running Python, Java, or Node on their Pi's, there's no reason why I shouldn't be able to run CFML.  If you want to play around with CFML, CommandBox is a great place to start.  It's only 34 MB, and runs all on its own without the need for any other server software installed.

http://ortus.gitbooks.io/commandbox-documentation/content/getting_started_guide.html