BoxLang ๐Ÿš€ A New JVM Dynamic Language Learn More...

Default ColdBox App Template For BoxLang

v8.2.0+7 MVC


ColdBox Snapshots Total Downloads Latest Stable Version Apache2 License

Copyright Since 2005 ColdBox Platform by Luis Majano and Ortus Solutions, Corp
www.coldbox.org | www.ortussolutions.com


๐Ÿš€ ColdBox 8 BoxLang Application Template

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.

โš™๏ธ Requirements

Before getting started, ensure you have the following installed on your operating system:

  1. BoxLang OS - Operating System Binary
  2. CommandBox - CLI toolchain, package manager, and server runtime
  3. Maven - Java dependency manager (Optional, only if you need Java dependencies)

โšก Quick Installation

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! ๐ŸŽŠ

โšก Vite Frontend Build System

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.

๐Ÿ“‚ Asset Structure:

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

๐Ÿš€ Using Vite

Development Mode (Hot Module Replacement)

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.

Production Build

npm run build

Compiles and optimizes assets for production, outputting them to public/includes/. The generated files include content hashes for cache busting.

๐Ÿ“ Including Assets in Views

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/

๐ŸŽจ Customizing Vite

Change Output Directory

coldbox({
    input: [ "resources/assets/css/app.css", "resources/assets/js/app.js" ],
    refresh: true,
    publicDirectory: "public",
    buildDirectory: "dist"      // Assets output to public/dist/
})

Add More Entry Points:

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
})

Configure Refresh Paths:

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 Script (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

What Build.bx Does:

The build process performs the following steps:

  1. ๐Ÿงน Clean Build Directory: Removes any existing build/ folder and creates a fresh structure
  2. ๐Ÿ“ Copy Sources: Copies application files (app/, modules/, public/, runtime/) to the build package
  3. โŠ˜ Smart Exclusions: Automatically excludes:
    • Log files and directories (logs/, *.log)
    • System files (.DS_Store, Thumbs.db)
    • Hidden files and folders (.git, .gitignore, etc.)
  4. ๐Ÿท๏ธ Build ID: Creates a build information file with project name, version, and timestamp
  5. ๐Ÿ”จ Compilation: Compiles BoxLang sources in app/ and public/ to optimized bytecode
  6. ๐Ÿ“ฆ Distribution Package: Creates a ZIP file: build/distributions/{projectName}-{projectVersion}.zip
  7. ๐Ÿ” Checksums: Generates security checksums (MD5, SHA-256, SHA-512) for integrity verification

Build Output Structure:

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

Customizing the Build:

You can customize what gets included or excluded by editing the Build.bx file's initialization section. The build script uses two configurable arrays:

๐Ÿ“ฆ Sources Array - What to Include

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
];

๐Ÿšซ Excludes Array - What to Skip

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:

  • Use $ to match end of string: \.log$ matches files ending in .log
  • Use / to match directories: logs/ matches any logs directory
  • Use \. to escape dots: \.DS_Store$ matches .DS_Store files
  • Use .* for wildcards: temp.* matches anything starting with temp

๐Ÿ”ง Example: Custom Build Configuration

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 running Setup.bx to ensure you're not packaging unnecessary setup resources!

Deploying Your Build:

Once the build completes, you can:

  1. Upload the ZIP: Deploy {projectName}-{version}.zip to your server
  2. Verify Integrity: Use the checksum files to verify the package wasn't corrupted during transfer
  3. Extract & Run: Unzip on your server and start with CommandBox
# 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!

๐Ÿ“Application Structure

This ColdBox 8 application follows a clean, modern architecture with the following structure:

๐Ÿ—๏ธ ColdBox Application (/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 Web Root (/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

๐Ÿ”ง Configuration & Build

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

๐Ÿ—บ๏ธ BoxLang Mappings

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:

๐Ÿ“ Core Application Mappings

"/public": "${user-dir}/public",           // Public web root
"/app": "${user-dir}/app",                 // ColdBox application
"/tests": "${user-dir}/tests",         // Test suites (Can be removed for production)

๐Ÿ—๏ธ Framework & Library Mappings

"/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

๐Ÿ“ฆ Module Mappings

"/modules": "${user-dir}/modules"    // Application modules directory

๐Ÿ”ง External vs Internal Mappings

  • External mappings ("external": true) - Can be accessed via web requests and file resolution
  • Internal mappings ("external": false) - Only accessible programmatically, not via web requests

This mapping structure ensures your ColdBox application has clean, predictable paths for all its components while maintaining security by controlling web accessibility! ๐Ÿ›ก๏ธ

โ˜• Java Dependencies

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. ๐Ÿ“ฆ

๐Ÿณ Dockerfile

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

๐Ÿ™ Docker Compose Stack

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

๐Ÿ’ป VSCode Helpers

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 ๐Ÿš€

๐ŸŽ‰ Welcome to ColdBox

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:

๐Ÿ“š Learning ColdBox

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 Sponsors

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 โค๏ธ

๐Ÿ™ THE DAILY BREAD

"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12

Changelog

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.


Unreleased

8.2.0 - 2025-10-10

8.1.1 - 2025-10-10

Fixed

  • ColdBox.bx syntax update

8.1.0 - 2025-10-10

8.0.0 - 2025-10-10

Added

  • ColdBox 8 readyness

1.1.0 - 2025-06-07

1.0.0 - 2025-04-29

  • First creation of the changelog file.
  •   Ortus Solutions
  • Published
  • 8.2.0+7 is the latest of 9 release(s)
    Published
  • Published on {{ getFullDate("2025-10-10T14:37:01Z") }}

$ box install cbtemplate-boxlang

No collaborators yet.
  • {{ getFullDate("2025-10-08T11:43:27Z") }}
  • {{ getFullDate("2025-10-10T14:37:01Z") }}
  • 48
  • 40