azu generate
The azu generate command is one of the most powerful features of Azu CLI. It creates various components for your application, following Azu conventions and best practices. This command helps you rapidly develop applications by generating boilerplate code, tests, and associated files.
Overview
azu generate <generator_type> <name> [attributes] [options]Available Generators
endpoint
e, controller
HTTP endpoints with full CRUD operations
model
m
CQL ORM models with validations
service
s
Business logic services following DDD patterns
middleware
mw
HTTP middleware components
contract
c
Request/response validation contracts
page
p
Page components for rendering HTML
component
comp
Live interactive components with real-time features
validator
v, val
Custom validation logic
migration
mig
Database migration files
scaffold
Complete CRUD resource (all of the above)
Global Options
--force
Overwrite existing files without prompting
false
--skip-tests
Don't generate test files
false
--skip-routes
Don't register routes automatically
false
--help
Show help for the generator
Endpoint Generator
Generates HTTP endpoints (controllers) for handling web requests.
Usage
Examples
Generated Files
Example Generated Endpoint
Options
--api
Generate API-only endpoints (no pages/templates)
--actions <list>
Specify which actions to generate
Model Generator
Generates CQL ORM models with validations and relationships.
Usage
Examples
Field Types
string
String
VARCHAR/TEXT
text
String
TEXT
integer
Int32
INTEGER
bigint
Int64
BIGINT
float
Float64
FLOAT
decimal
BigDecimal
DECIMAL
boolean
Bool
BOOLEAN
date
Date
DATE
time
Time
TIMESTAMP
json
JSON::Any
JSON/JSONB
uuid
UUID
UUID
Generated Files
Example Generated Model
Options
--validations
Add common validations
--timestamps
Add created_at/updated_at fields
--uuid
Use UUID as primary key
Service Generator
Generates service classes for encapsulating business logic.
Usage
Examples
Generated Files
Example Generated Service
Component Generator
Generates live, interactive components for real-time features.
Usage
Examples
Generated Files
Example Generated Component
Options
--websocket
Enable WebSocket support for real-time updates
--events <list>
Specify custom event handlers
Migration Generator
Generates database migration files.
Usage
Examples
Generated Files
Example Generated Migration
Migration Types
Based on the migration name, different templates are used:
create_*_table- Creates a new tableadd_*_to_*- Adds columns to existing tableremove_*_from_*- Removes columns from tableadd_index_*- Adds database index
Scaffold Generator
Generates a complete CRUD resource with all associated files.
Usage
Examples
Generated Files
The scaffold generator creates:
Model with validations
All CRUD endpoints
Request contracts
Page components
HTML templates
Test files
Database migration
Advanced Usage
Custom Templates
You can create custom generator templates:
Generator Hooks
Add custom logic before/after generation:
Batch Generation
Generate multiple components at once:
Troubleshooting
Common Issues
File Already Exists
Invalid Attribute Syntax
Generator Not Found
Best Practices
Use descriptive names for generators
Plan your attributes before generating
Generate tests alongside code
Use scaffold for rapid prototyping
Customize generated code to fit your needs
Related Documentation:
Generators Guide - Detailed generator documentation
Project Structure - Understanding generated files
Development Workflows - Using generators in development
Last updated