Skip to main content

CLI (vania_cli)

The vania_cli package provides command-line tools for project creation, code generation, development server management, database migrations, and production builds.

Installation

dart pub global activate vania_cli

Commands

Project Management

CommandDescription
vania create <name>Create a new Vania project
vania serveStart the dev server with hot reload
vania serve --host <h> --port <p>Bind a specific host/port
vania serve --no-reloadRestart on change instead of hot reloading
vania downStop the running development server
vania buildCompile to a native executable
vania updateUpdate the CLI to the latest version
vania key:generateGenerate and write a new APP_KEY
vania route:listList all registered routes

Code Generation

CommandDescription
vania make:controller <name>Generate a resource controller
vania make:model <name>Generate a model class
vania make:middleware <name>Generate a middleware class
vania make:migration <name>Generate a migration file
vania make:provider <name>Generate a service provider
vania make:mail <name>Generate a mailable class
vania make:seeder <name>Generate a database seeder
vania make:authGenerate the personal access tokens migration

Database

CommandDescription
vania migrateRun pending migrations
vania migrate:freshDrop all tables and re-run migrations
vania migrate:seedRun database seeders

Creating a Project

vania create my_blog
cd my_blog

This clones the official template, sets up the project name, generates an .env file, and installs dependencies.

Development Server

vania serve

The server watches for .dart file changes and automatically restarts. Output shows the URL where your application is running.

To stop:

vania down

Or press Ctrl+C in the terminal.

Code Generation Examples

Controller

vania make:controller post

Generates lib/app/http/controllers/post_controller.dart:

class PostController extends Controller {
Future<Response> index() async {
return Response.json({});
}

Future<Response> create() async {
return Response.json({});
}

Future<Response> store(Request req) async {
return Response.json({});
}

Future<Response> show(int id) async {
return Response.json({});
}

Future<Response> edit(int id) async {
return Response.json({});
}

Future<Response> update(Request req, int id) async {
return Response.json({});
}

Future<Response> destroy(int id) async {
return Response.json({});
}
}

final PostController postController = PostController();

Model

vania make:model post

Generates lib/app/models/post.dart:

class Post extends Model {
Post() {
super.table('posts');
}
}

Migration

vania make:migration create_posts_table

Generates a timestamped migration file and adds it to the migration registry.

Service Provider

vania make:provider cache

Generates lib/app/providers/cache_service_provider.dart with register() and boot() stubs.

Production Build

vania build

Compiles bin/server.dart to a native executable at bin/server. The resulting binary is self-contained — it runs without the Dart SDK on the target machine.

Deploy the binary along with your .env, public/, and storage/ directories.