A Rust web framework inspired by Laravel, built on Axum, Tokio, and SeaORM.
cargo install larastvel-new
larastvel-new my-app
cd my-app
cargo build
cargo run
# → http://localhost:8080git clone https://github.com/sonyarianto/larastvel.git
cd larastvel
cargo run
# → http://localhost:8080cargo install larastvel-cli
larastvel serve
larastvel make controller PostControllerDefine routes in src/routes/:
// src/routes/web.rs
pub fn web(router: &Registrar) {
router.get("/", || async {
larastvel_core::axum::response::Html("<h1>Welcome</h1>")
});
}
// src/routes/api.rs
pub fn api(router: &Registrar) {
router.group("/api", |r| {
r.get("/health", || async {
larastvel_core::axum::response::Json(serde_json::json!({"status": "ok"}))
});
});
}The config/ directory holds per-section TOML files. Missing sections use
built-in defaults.
# config/app.toml
name = "Larastvel"
url = "http://localhost:8080"
env = "local"
debug = true
key = "" # generate with `larastvel key:generate`# config/database.toml
driver = "sqlite" # sqlite, postgres, mysql
host = "127.0.0.1"
port = 3306
database = "larastvel"
username = "root"
password = ""See Configuration Reference for all options.
| Area | Capabilities |
|---|---|
| Auth | JWT tokens, AuthenticatedUser extractor, auth middleware, password reset, email verification |
| Authorization | Gates, policies, before/after hooks, authorize() / require_ability |
| Broadcasting | Pusher, Ably, Log, Native (self-hosted WebSocket) broadcast drivers |
| Caching | CacheManager with array, file, database stores, TTL, remember(), batch ops |
| CLI | 19 make:* generators, serve, migrate, route:list, config:cache, schedule:run, queue:work, and more |
| Console | routes/console.rs, Command trait, ConsoleKernel, scheduled command registration |
| Database | SQLite/Postgres/MySQL via SeaORM, migrations, seeders, model factories (Faker) |
| Encryption | AES-256-GCM (Encrypter), bcrypt hashing (hash::make / hash::check) |
| Events | EventService, dispatch(), listen(), fake() / assert_dispatched() |
| File Storage | Filesystem trait, LocalDisk driver, StorageManager |
| Localization | JSON translation files, __(), trans_choice(), pluralization |
SMTP (STARTTLS) and log mailers, Mailable builder, MailManager |
|
| Notifications | Mail, Database, Broadcast, SMS, Webhook channels, multi-channel via() |
| Pagination | Paginator<T>, PaginationParams, to_json(), IntoResponse |
| Queue | Sync, in-memory, database queues, worker, dispatch(), ShouldQueue |
| Rate Limiting | Token bucket, RateLimiterRegistry, Axum middleware |
| Routing | Groups, prefixes, middleware stack, #[controller] / #[derive(Resource)] macros, WebSocket routes |
| Scaffolding | larastvel-new generates a complete project with routes, models, migrations, Vite |
| Session | Encrypted cookie store, flash data, CSRF protection, SessionLayer middleware (auto-wired) |
| SMS | Log and Vonage senders, SmsMessage builder |
| Task Scheduling | Cron expression parser, Schedule builder, ScheduleManager |
| Templating | Tera engine + Blade directives (@auth, @csrf, @error, @guest, @method) |
| Testing | TestClient, TestResponse, RefreshDatabase, 1000+ tests |
| Validation | 24 built-in rules (incl. DB-backed unique/exists), ValidatedJson/ValidatedQuery extractors |
| Vite | Manifest-based asset tag generation |
| AI | AI SDK foundation — text generation, streaming, structured output, embeddings with 30-day caching, OpenAI-compatible provider, FakeAi |
| File | Key | Default | Description |
|---|---|---|---|
app.toml |
name |
"Larastvel" |
Application name |
url |
"http://localhost:8080" |
Base URL | |
env |
"local" |
Environment (local, production, testing) |
|
debug |
true |
Enable debug output | |
key |
none | 32-byte base64 encryption key (generate via key:generate) |
|
database.toml |
driver |
"sqlite" |
sqlite, postgres, mysql |
host |
"127.0.0.1" |
Database host | |
port |
3306 |
Database port | |
database |
"larastvel" |
Database name / SQLite filename | |
username |
"root" |
Database user | |
password |
"" |
Database password | |
logging.toml |
level |
"debug" |
Log level |
format |
"text" |
Output format (text, json) |
|
view.toml |
engine |
"tera" |
Template engine |
paths |
["resources/views"] |
Template search paths | |
broadcasting.toml |
default |
"log" |
Default driver |
app_id / key / secret |
"" |
Pusher/Ably credentials | |
cluster |
"mt1" |
Pusher cluster | |
encrypted |
true |
TLS for Pusher | |
cache.toml |
default |
"array" |
Cache driver |
prefix |
"" |
Key prefix | |
table |
"cache" |
DB table (database driver) | |
file_path |
"storage/framework/cache/data" |
File path (file driver) | |
password_reset.toml |
table |
"password_reset_tokens" |
DB table |
expire_seconds |
3600 |
Token lifetime | |
throttle_seconds |
60 |
Min seconds between resets |
A single config.toml at the project root still works (legacy format), but
config/ takes precedence.
Ready-to-run examples in examples/:
| Example | What it demonstrates |
|---|---|
auth_service_provider |
Auth, password reset, email verification working together |
multi_channel_notification |
Broadcasting on multiple channels |
unified_dashboard |
WebSocket dashboard with broadcast log, auth, rate limiting |
websocket_broadcast |
Self-hosted WebSocket via NativeBroadcaster |
mail_controller, sms_controller, notification_controller |
Mail/SMS/Notification sending |
password_reset_controller |
Password reset flow |
Run any example: cargo run --example <name>
┌──────────────────────────────────────────────────────┐
│ Application │
│ ┌──────────┐ ┌──────────┐ ┌────────────────────┐ │
│ │ Config │ │ DB │ │ Service Container │ │
│ │ (TOML) │ │ (SeaORM) │ │ (TypeId-based) │ │
│ └──────────┘ └──────────┘ └────────────────────┘ │
│ ┌────────────────────────────────────────────────┐ │
│ │ Router (Axum + Registrar) │ │
│ │ Routes → Groups → Middleware → Controllers │ │
│ └────────────────────────────────────────────────┘ │
│ ┌──────────┐ ┌──────────┐ ┌────────────────────┐ │
│ │ Session │ │ Cache │ │ Queue / Events │ │
│ │ + CSRF │ │ (stores) │ │ + Notifications │ │
│ └──────────┘ └──────────┘ └────────────────────┘ │
└──────────────────────────────────────────────────────┘
crates/
larastvel-core/ Framework core (router, DB, config, view, middleware, etc.)
larastvel-cli/ Artisan-like CLI binary
larastvel-macros/ Procedural macros (Resource, controller, route)
larastvel-tinker/ Interactive REPL binary
larastvel-new/ Project scaffolding binary
larastvel-testing/ Test utilities (TestClient, TestResponse, RefreshDatabase)
src/ Application entrypoint
config/ Per-section TOML config files
resources/ Views, CSS, JS
examples/ Self-contained example apps
| Concern | Laravel | Larastvel |
|---|---|---|
| HTTP | Symfony/Illuminate | Axum 0.8 |
| Runtime | PHP-FPM | Tokio |
| ORM | Eloquent | SeaORM 1.x |
| Templating | Blade | Tera |
| CLI | Artisan | Clap |
| Config | PHP arrays / .env |
TOML / .env |
| Logging | Monolog | Tracing |
| Migrations | Phinx | sea-orm-migration |
| Asset bundling | Vite | Vite (manifest-based) |
# Run all tests
cargo test --workspace
# Check formatting
cargo fmt --check
# Lint
cargo clippy --workspace
# Run a specific example
cargo run --example unified_dashboardMIT