Hidden Gems in CF2018, part 4 – Dev features: CFML REPL, CFFiddle, and REST Playground

February 21, 2019
ColdFusion troubleshooter
Wizard 33 posts
Followers: 35 people
3

Hidden Gems in CF2018, part 4 – Dev features: CFML REPL, CFFiddle, and REST Playground

ColdFusion troubleshooter
Wizard 33 posts
Followers: 35 people
February 21, 2019

In part 4 of this series on CF2018 Hidden gems, we turn our attention to more developer-oriented features. First up, this article will discuss the following new developer-oriented features that you might miss:

  • CF2018’s new command-line CFML REPL
  • CFFiddle site, for testing/sharing CFML code
  • CF2018 REST Playground feature, for testing REST calls

And here are the previous 3 parts so far:

And don’t worry, if as a developer you were more interested to know instead about language additions and changes, I’ll cover that in the next part. But don’t drop off here: perhaps some aspects of these new features may benefit you in your development.

CF2018’s new command-line CFML REPL

If you’re familiar with the concept of a REPL (read-eval-print-loop) command-line tool, as is offered with many modern platforms, you may have wished for that in CF (or you may have looked to and found great value in the open source Commandbox implementation of a CF CLI,,REPL and more.

You may also know that CF2016 did introduce a new command-line interface (CLI) for CF. It was rather simplistic: it allowed you to point to a cfm file to be executed at the command line, via the cf.bat or cf.sh file found in CF’s cfusion/bin folder. It did not require that CF be running. It could run such a CFM file independently from a running CF engine, could leverage an application.cfc, and more. This could be useful, perhaps, for automating execution of CFM files as other than web requests, such as for operating system scheduled tasks or CRON jobs, or perhaps in some scripted configuration process.

But that wasn’t a true REPL, where you would actually write and execute CFML from the command line, interactively. CF2018 adds that with the new CF REPL. And you still use the same cf.bat or cf.sh to run it, but if you don’t pass a cfm file name as an argument, it presumes to open in interactive mode, ready for you to enter cfscript and more. Here’s a screenshot if starting it up and using its “help” command:

The value of a REPL is not just that you can write code at the command line, but that as you write it, you see displayed the result of expressions, functions, assignments, and more. You can also output to the command line with writeOutput and writeDump, of course. Again, CF need not be running. You can also type help (as shown above), to get more.
But for still more details, including examples, let me point you to Adobe resources which also explain how you can run (and terminate) multi-line statements, how to prevent that automatic display of output (if you prefer), and more:

Sometimes, you may want to work with CFML and you don’t have CF even installed, or you don’t want to figure out how to get to the command line. There’s a useful solution from Adobe for that…

CFFiddle site, for testing/sharing CFML code

Folks in other platforms have had “fiddle” sites where you could easily “try out” code easily, such jsfiddle.net and phpfiddle.org, where folks could enter and execute those languages without installing anything at all.

For those who didn’t know, Adobe has had a similar web-based CF Fiddle site, CFFiddle.org site for over a year. So it’s not technically new for CF2018, but it does support running code in CF2018 (or CF2016), and it was updated in the CF2018 timeframe to no longer REQUIRE that one login to use the tool. (Curiously, if you DO choose to login, it still offers only Facebook and Google authentication, not Adobe account authentication.)

Like the other fiddle sites, it’s an interactive web-site for running CFML, including code coloring. You can save scripts to share with others, and more.

Speaking of sharing scripts, the CF docs team is working to make many of the CF docs have links to such “live” demos, using CFFiddle. People are also using it to share links to demo problems in the CF bug tracker, and more. For more on the docs team efforts, see these blog posts:

And to find out more about the CFFiddle project, or to share feedback, see these Adobe blog posts:

Before leaving this subject, I would be remiss not to mention that there was a similar kind of site, to test any CFML, which long-preceded CFFiddle, at trycf.com, created and maintained by Abram Adams. It not only lets you run CF 2018 and 2016, but also CF 11 and 10, as well as Lucee 5 and 4.5, and even Railo 4.2. It also supports saving scripts as gists, and more. (It was also designed to go beyond just such code editing/execution to also be a place where tutorials would be shared and community events would be tracked, though at this writing in 2019, none of those are dated beyond 2015.)

CF2018 REST Playground feature, for testing REST calls

Finally, in the same vein of ways to “try things out”, CF 2018 adds still another means to do that with REST processing, in the new REST Playground feature.

This tool provides a new interactive way to work with CF REST services. It’s a web app bundled with the CF 2018 Admin, to help visualize, test, and debug REST services, as you can see above. It works with all REST apps currently registered to CF, and it can be used to create and then add/register REST apps into CF. It can be launched from the CF Admin “REST Services” page, or via a URL as :/restplay, though for security reasons that’s supported only via CF’s built-in web server only. It also does require that CF’s “developer profile” (added in CF2016) be enabled.

For more on the REST playground, including a several-screen walkthrough of using it, see these Adobe resources:

Coming up in part 5

In part 5, we’ll wrap up our focus on developer-oriented hidden gems by pointing out CFML language additions and enhancements in CF2018. But we won’t be done! There are still “other” hidden gems I’ll have to share beyond that. Until those, do check out the other parts so far, again as listed in the part 1 overview of the series.

Comments (3)
2019-04-08 03:41:51
2019-04-08 03:41:51

I should have mentioned in this 4th part another aspect of working with CFML in new ways (adding to the REPL, CFFiddle, and REST playground): if you didn’t know, Adobe has released Docker images since CF2016, and they have been updated for CF2018 (and with each of its updates).

For more on that, see these resources:

 

Like
2019-02-21 17:39:17
2019-02-21 17:39:17

Good point, Tyler. And I could have mentioned postman and others. I just thought that could start getting a bit far afield of CF-specific tools. 🙂

And yes, I do mention jsfiddle and phpfiddle in the section before, but that was more in the guise of existing similar web-based fiddle for other languages, and where some seeing them may have lamented that there was none for CF.

Writing is always a balancing act, choosing what and what not to say–especially for one like me who is accused by many of being already excessively wordy! 🙂

Like
2019-02-21 14:30:37
2019-02-21 14:30:37

For anyone looking for other tools for REST development, the Chrome extension Restlet Client works quite well.  However I have not used their service nor paid features.

Like
Add your comment