BoxLang ๐ A New JVM Dynamic Language Learn More...
Copyright Since 2005 ColdBox Platform by Luis Majano
and Ortus Solutions, Corp
www.coldbox.org | www.ortussolutions.com
Welcome to the modern ColdBox 8 BoxLang application template! ๐ This template provides a solid foundation for building enterprise-grade HMVC (Hierarchical Model-View-Controller) web applications using the BoxLang runtime. Perfect for developers looking to leverage the power of ColdBox with the performance and modern features of BoxLang.
Before getting started, ensure you have the following installed on your operating system:
In order to work with this template, you need to have CommandBox and the BoxLang operating system runtime installed on your machine. CommandBox is the application server of choice for BoxLang applications. Please note that running BoxLang web applications is different than the BoxLang OS runtime. The BoxLang OS runtime is used to run BoxLang scripts and command line applications, while CommandBox is used to run web applications.
# Create a new ColdBox application using this BoxLang template
box coldbox create app --boxlang
# Start up the web server
box server start
Your application will be available at
http://localhost:8080
๐
Code to your liking and enjoy! ๐
If you chose to use Vite during setup, this template includes a modern frontend build system with Vue 3 and Tailwind CSS support. Vite provides lightning-fast hot module replacement (HMR) and optimized production builds.
resources/
โโโ assets/
โโโ css/
โ โโโ app.css # Main stylesheet (Tailwind)
โโโ js/
โโโ app.js # Main JavaScript (Vue 3 app)
public/
โโโ includes/ # Compiled assets (generated by Vite)
โโโ manifest.json # Asset manifest for production
โโโ assets/
โโโ app-[hash].css # Compiled & hashed CSS
โโโ app-[hash].js # Compiled & hashed JS
npm run dev
This starts the Vite development server with HMR at
http://localhost:5173
. The ColdBox application
automatically detects the dev server and loads assets from it.
npm run build
Compiles and optimizes assets for production, outputting them to
public/includes/
. The generated files include content
hashes for cache busting.
The vite()
helper function automatically loads assets
based on the environment:
<!--- In your Main.bxm layout --->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
#vite([
"resources/assets/css/app.css",
"resources/assets/js/app.js"
])#
</head>
Development: Loads from Vite dev server
(http://localhost:5173
) Production:
Loads compiled assets from public/includes/assets/
coldbox({
input: [ "resources/assets/css/app.css", "resources/assets/js/app.js" ],
refresh: true,
publicDirectory: "public",
buildDirectory: "dist" // Assets output to public/dist/
})
coldbox({
input: [
"resources/assets/css/app.css",
"resources/assets/js/app.js",
"resources/assets/js/admin.js", // Additional JS entry
"resources/assets/css/admin.css" // Additional CSS entry
],
refresh: true
})
coldbox({
input: [ "resources/assets/css/app.css", "resources/assets/js/app.js" ],
refresh: [
"app/layouts/**",
"app/views/**",
"app/config/Router.bx",
"app/handlers/**/*.bx" // Also refresh on handler changes
]
})
๐ Learn More: Check out the coldbox-vite-plugin documentation and Vite documentation for advanced configuration options.
Build.bx
)The Build.bx script compiles and packages your application for distribution. It creates optimized, production-ready builds that can be deployed to any environment.
boxlang Build.bx
The build process performs the following steps:
build/
folder and creates a fresh structureapp/
, modules/
, public/
,
runtime/
) to the build packagelogs/
, *.log
).DS_Store
, Thumbs.db
).git
,
.gitignore
, etc.)app/
and public/
to optimized bytecodebuild/distributions/{projectName}-{projectVersion}.zip
build/
โโโ package/ # Staged files ready for distribution
โ โโโ app/ # Compiled application code
โ โโโ modules/ # Application modules
โ โโโ public/ # Compiled public assets
โ โโโ runtime/ # Runtime configuration (without logs)
โ โโโ {projectName}-{version}.md # Build information
โโโ distributions/ # Final distribution files
โโโ {projectName}-{version}.zip
โโโ {projectName}-{version}.zip.md5
โโโ {projectName}-{version}.zip.sha256
โโโ {projectName}-{version}.zip.sha512
You can customize what gets included or excluded by editing the
Build.bx
file's initialization section. The build script
uses two configurable arrays:
Controls which directories and files get packaged in your distribution:
// Source directories to package
variables.sources = [
".cbmigrations.json", // Database migrations state
"box.json", // Project metadata
"app", // Your ColdBox application
"modules", // Installed modules
"public", // Web root with assets
"runtime" // BoxLang runtime config
];
To add more sources, simply append to the array:
variables.sources = [
".cbmigrations.json",
"box.json",
"app",
"modules",
"public",
"runtime",
"config", // Add custom config directory
"resources/database" // Include database resources
];
Uses regex patterns to exclude files/directories from the build:
// Files and folders to exclude from the build (regex patterns)
variables.excludes = [
"logs/", // Log directories
"\.DS_Store$", // macOS system files
"Thumbs\.db$" // Windows system files
];
Common exclusion patterns:
variables.excludes = [
"logs/", // Exclude all log directories
"\.log$", // Exclude .log files
"\.tmp$", // Exclude .tmp files
"test-results/", // Exclude test output
"node_modules/", // Exclude npm dependencies
"\.git", // Exclude git repository
"\.env", // Exclude environment files
"\.bak$", // Exclude backup files
"resources/vite/", // Exclude vite resources after setup
"resources/rest/" // Exclude rest resources after setup
];
Regex Pattern Tips:
$
to match end of string: \.log$
matches files ending in .log
/
to match directories: logs/
matches any logs
directory\.
to escape dots: \.DS_Store$
matches .DS_Store
files.*
for wildcards: temp.*
matches
anything starting with temp
function init(){
// ... existing code ...
// Custom sources for your project
variables.sources = [
".cbmigrations.json",
"box.json",
"app",
"modules",
"public",
"runtime",
"custom-config", // Add your custom directory
"static-files" // Add static file directory
];
// Comprehensive exclusions
variables.excludes = [
"logs/", // No log files
"\.DS_Store$", // No macOS files
"Thumbs\.db$", // No Windows files
"test-results/", // No test outputs
"\.env\..*", // No environment files
"resources/vite/", // No vite setup resources
"resources/rest/", // No rest setup resources
"resources/docker/", // No docker setup resources
"Setup\.bx$" // No setup script
];
return this;
}
๐ก Pro Tip: Review your
variables.excludes
after runningSetup.bx
to ensure you're not packaging unnecessary setup resources!
Once the build completes, you can:
{projectName}-{version}.zip
to your server# On your server
unzip cbtemplate-boxlang-1.1.0.zip
cd cbtemplate-boxlang-1.1.0
box server start
๐ Pro Tip: Integrate
Build.bx
into your CI/CD pipeline to automatically build and deploy your application on every release!
This ColdBox 8 application follows a clean, modern architecture with the following structure:
/app/
)This folder contains the main ColdBox application code via conventions, including configuration files, event handlers, models, views, and more. This is where you will be coding most of your application logic.
app/
โโโ ๐ง config/ # Configuration files (Optional)
โ โโโ CacheBox.bx # Caching configuration
โ โโโ ColdBox.bx # Main framework settings
โ โโโ Router.bx # URL routing definitions
โ โโโ Scheduler.bx # Task scheduling
โ โโโ WireBox.bx # Dependency injection
โโโ ๐ฎ handlers/ # Event handlers (controllers)
โโโ ๐ ๏ธ helpers/ # Application helpers (Optional)
โโโ ๐จ layouts/ # View layouts
โโโ ๐ logs/ # ColdBox logs (Optional)
โโโ ๐๏ธ models/ # Business logic models
โโโ ๐ฆ modules_app/ # Application-specific modules (Optional)
โโโ ๐๏ธ views/ # View templates
/public/
)This folder contains all the publicly accessible assets and the main application entry point. The CommandBox or MiniServer or Whatever server will point to this folder as the web root.
public/
โโโ ๐ฑ Application.bx # Web-facing application Bootstrap
โโโ ๐ฏ index.bxm # Main entry point (Empty)
โโโ ๐ผ๏ธ favicon.ico # Site icon
โโโ ๐ค robots.txt # Search engine directives
โโโ ๐ฆ includes/ # CSS, JS, images or any resources you want
This folder contains configuration files, dependencies, Docker setup, and runtime environment.
โโโ ๐ box.json # CommandBox dependencies and project descriptor
โโโ ๐๏ธ pom.xml # Maven dependencies (Optional)
โโโ ๐ฅ๏ธ server.json # CommandBox Server configuration
โโโ ๐ณ docker/ # Docker configuration (Optional)
โโโ ๐งช tests/ # Test suites (NOT OPTIONAL)
โโโ ๐ฆ modules/ # ColdBox application modules (Managed by CommandBox)
โโโ โ๏ธ runtime/ # BoxLang runtime environment overrides and resources
โ โโโ ๐ง boxlang.json # Custom BoxLang configuration overrides
โ โโโ global/ # Global classes and BoxLang components (Optional)
โ โ โโโ classes/ # Global BoxLang classes
โ โ โโโ components/ # Global BoxLang components
โ โโโ lib/ # Runtime libraries (Managed by Maven/CommandBox)
โ โโโ logs/ # BoxLang logs
โโโ ๐ resources/ # ColdBox/CommandBox module resources
โโโ migrations/ # Database migrations (cbmigrations)
โโโ seeders/ # Database seeders
โโโ swagger/ # API documentation (cbswagger)
โโโ other module assets/ # Various module-specific resources
This template comes pre-configured with essential BoxLang mappings in
the runtime/config/boxlang.json
file to make development
seamless. These mappings provide convenient shortcuts to access
different parts of your application:
"/public": "${user-dir}/public", // Public web root
"/app": "${user-dir}/app", // ColdBox application
"/tests": "${user-dir}/tests", // Test suites (Can be removed for production)
"/coldbox": "${user-dir}/runtime/lib/coldbox", // ColdBox framework
"/coldbox/system/exceptions": "...coldbox/system/exceptions", // ColdBox exceptions (external)
"/testbox": "${user-dir}/runtime/lib/testbox" // TestBox testing framework
"/modules": "${user-dir}/modules" // Application modules directory
"external":
true
) - Can be accessed via web requests and file resolution"external":
false
) - Only accessible programmatically, not via web requestsThis mapping structure ensures your ColdBox application has clean, predictable paths for all its components while maintaining security by controlling web accessibility! ๐ก๏ธ
If your project relies on Java third-party dependencies, you can use
the included Maven pom.xml
file in the root. You can add
your dependencies there and then run the mvn install
command to download them into the runtime/lib
folder. The
BoxLang application will automatically class load all the jars in that
folder for you! ๐ฏ
You can also use the mvn clean
command to remove all the
jars. ๐งน
You can find Java dependencies here: https://central.sonatype.com/.
Just grab the Maven coordinates and add them to your
pom.xml
file. ๐ฆ
We have included a docker/Dockerfile
so you can build docker containers from your source code. We have
also added two scripts in your box.json
so you can build
the docker image and run the docker image using our CommandBox
Docker containers.
# Build a docker **container**
run-script docker:build
# Run the container
run-script docker:run
# Go into the container's bash prompt
run-script docker:bash
We have included a docker/docker-compose.yaml
stack that can be used to run the application in a container
alongside a database. We have included support for MySQL, PostgreSQL
and MSSQL. We have also included the run-script
docker:stack
command you so you compose the stack up or down.
run-script docker:stack up
run-script docker:stack down
We have included two vscode helpers for you:
.vscode/settings.json
- Includes introspection helpers
for ColdBox and TestBox ๐.vscode/tasks.json
- Tasks to assist in running a Test
Bundle and a CommandBox Task โกWe have included two custom tasks:
Run CommandBox Task
- Open a CommandBox task and run it ๐โโ๏ธRun TestBox Bundle
- Open the bundle you want to test
and then run it ๐งชTo run the custom tasks open the command palette and choose
Tasks: Run Build Task
or the shortcut โงโB
๐
ColdBox Hierarchical MVC is the de-facto enterprise-level HMVC framework for BoxLang and CFML developers. It's professionally backed, conventions-based, modular, highly extensible, and productive. Getting started with ColdBox is quick and painless. ColdBox takes the pain out of development by giving you a standardized methodology for development with features such as:
ColdBox is the defacto standard for building modern BoxLang and ColdFusion (CFML) applications. It has the most extensive documentation of all modern web application frameworks. ๐
If you don't like reading so much, then you can try our video learning platform: CFCasts (www.cfcasts.com) ๐ฅ
ColdBox is a professional open-source project and it is completely funded by the community and Ortus Solutions, Corp. Ortus Patreons get many benefits like a cfcasts account, a FORGEBOX Pro account and so much more. If you are interested in becoming a sponsor, please visit our patronage page: https://patreon.com/ortussolutions โค๏ธ
"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
$
box install cbtemplate-boxlang