LogoLogo
InstallSource CodeIssuesSupport
v1.x
v1.x
  • Introduction
  • Essentials
    • Installation
    • Configuration
    • Creating Components
    • Rendering Views
    • Data Properties
    • Actions
    • Events
    • Lifecycle Events
  • Component Features
    • Redirecting
    • Logging
  • Templates
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Dirty States
    • Defer Loading
  • JS Integrations
    • AlpineJS
    • Inline Scripts
  • Testing
  • Security
  • Troubleshooting
  • CommandBox Commands
Powered by GitBook
On this page
  • Installing commandbox-cbwire
  • Creating Components

Was this helpful?

  1. Essentials

Creating Components

PreviousConfigurationNextRendering Views

Last updated 3 years ago

Was this helpful?

You can scaffold cbwire components quickly using the module.

Installing commandbox-cbwire

To get started open the binary or enter the shell by typing box in your terminal or console. Then let's install our scaffolding module.

install commandbox-cbwire

Creating Components

Let's create a Counter cbwire component that we will use to list our favorite movies.

cbwire create Counter
// Created /wires/Counter.cfc
// Created /views/wires/counter.cfm
// Created /tests/specs/integration/wires/CounterTest.cfc

You can provide named arguments as well.

cbwire create name=Counter views=false
// Created /wires/Counter.cfc
// Created /tests/specs/integration/wires/CounterTest.cfc

Below is the entire signature of arguments you can provide to the create command.

/**
    * @name Name of the component to create without the .cfc.
    * @actions Comma-delimited list of actions to generate.
    * @views Generate a view for the cbwire component.
    * @viewsDirectory Directory where your views are stored. Only used if views is set to true.
    * @integrationTests Generate the integration test component
    * @testsDirectory Your integration tests directory. Only used if integrationTests is true
    * @directory Base directory to create your handler in and creates the directory if it does not exist. Defaults to 'handlers'.
    * @description Component hint description.
    * @open Opens the component (and test(s) if applicable) once generated.
    **/
    function run(
    required string name,
    string actions = "",
    boolean views = true,
    string viewsDirectory = "views/wires",
    boolean integrationTests = true,
    string testsDirectory = "tests/specs/integration/wires",
    string directory = "wires",
    string description = "I am a new cbwire component.",
    boolean open = false
)
commandbox-cbwire
CommandBox