class
AmberCLI::Documentation::GenerationSystem
- AmberCLI::Documentation::GenerationSystem
- Reference
- Object
Overview
Code Generation System
The generate command creates application components following V2 patterns.
Available Generators
Model Generator
Creates a model with associated migration and spec:
amber generate model User name:string email:string
Controller Generator
Creates a controller with views and spec using Amber::Testing:
amber generate controller Posts index show
Scaffold Generator
Creates a complete CRUD resource with schema-based validation:
amber generate scaffold Post title:string body:text published:bool
Migration Generator
Creates a database migration file:
amber generate migration AddStatusToUsers
Job Generator
Creates a background job class extending Amber::Jobs::Job:
amber generate job SendNotification --queue=mailers --max-retries=5
Mailer Generator
Creates a mailer class extending Amber::Mailer::Base:
amber generate mailer User --actions=welcome,notify
Schema Generator
Creates a schema definition extending Amber::Schema::Definition:
amber generate schema User name:string email:string:required age:int32
Channel Generator
Creates a WebSocket channel extending Amber::WebSockets::Channel:
amber generate channel Chat
API Generator
Creates an API-only controller with model and schema:
amber generate api Product name:string price:float
Auth Generator
Creates an authentication system with login and registration:
amber generate auth
Field Types
Available field types for model, scaffold, schema, and api generators:
string- VARCHAR(255) / Stringtext- TEXT / Stringinteger,int,int32- INTEGER / Int32int64- BIGINT / Int64float,float64- DOUBLE PRECISION / Float64decimal- DECIMAL(10,2) / Float64bool,boolean- BOOLEAN / Booltime,timestamp- TIMESTAMP / Timeemail- VARCHAR(255) / String (with email format validation)uuid- VARCHAR(255) / String (with UUID format validation)reference- BIGINT / Int64
Schema Field Format
Schema fields support a :required suffix:
amber generate schema User name:string:required email:email:required age:int32