Embedded Server
Last updated
Last updated
One of the most useful features of CommandBox is the ability to start an ad-hoc server quickly and easily. Any folder on your hard drive can become the web root of a server. To start up the server, cd
into a directory containing some CFML code, and run the start
command. An available port will be chosen by default and in a few seconds, a browser window will open showing the default document (index.cfm
).
To stop the embedded server, run the stop
command from the same directory.
You can start as many embedded server instances as you want. Each running server will add an icon in your system tray with the logo of your currently running engine. Click on it for options:
Stop Server
Open Browser
Open Admin
Open File System
When a server finishes starting, CommandBox will automatically open up the root of the site in your default browser. You can control the URL that is opened with
You can change the browser used to open all sites or override just the browser for a single site:
Or you can disable this feature entirely
If you don't want the tray integration, then you can turn it off in your server.json
with this setting.
Or turn it off at a global level in your config settings.
CommandBox's embedded server does not require any prior installations of any CFML engine to work. It does not use Apache, IIS, or Nginx. A very lightweight Java web server called Undertow is used and a context is programmatically deployed via a WAR file.
You should still have all the options you need to set up most local development servers quickly. The web-based administrator is available to you where you can edit any setting, add data sources, CF mappings, and mail servers. To see a list of all the parameters you can pass to the server start
command, refer to the CommandBox API Docs or run server start help
command directly from the CLI.
Any ComandBox environment variables present in the shell will automatically be passed to the environment of the server process. This means, given an example like this:
The CFML code running that server process will be able to "see" the foo
environment variable.