Running revIgniter via the CLI

Controllers can also be loaded via the command-line interface (CLI). That's handy for:

Hello World Example

Following is a simple example demonstrating revIgniter's CLI capability. Create a file called, and put the following code in it:


put "index,hello,message" into gControllerHandlers

command hello
  if $_SERVER["PATH_TRANSLATED"] <> empty then
    put "This script can only be accessed via the command line."
    exit to top
  end if
end hello

command index
  put "Hello World!" & return
end index

command message
  put rigFetchSegment(3) into tTo
  if tTo is FALSE then
    put "Jane Doe" into tTo
  end if
  put "Hello" && tTo & "!" & return
end message

Save the file to your application/controllers/ folder. Normally you would load the controller using a URL similar to this:

Instead, we are going to open the terminal and navigate to our revIgniter project.

$ cd /path/to/project
$ path/to/LiveCode/executable hello

If you did it right, the terminal should print "Hello World!".

Note:  To avoid always having to write the complete path to the LC server executable, consider adding the location of LC server to the PATH environment variable.

Now add a third argument "message" to the command like:

$ path/to/LiveCode/executable hello message

This calls the "message" handler instead of the default handler (index). The output should be "Hello Jane Doe!"

You could replace "Jane Doe" by adding your name in a fourth argument like:

$ path/to/LiveCode/executable hello message "Your Name"

This should print "Hello Your Name!"

That's it!

That, in a nutshell, is all there is to know about controllers on the command line.