pub struct Config {Show 25 fields
pub app_name: String,
pub app_env: String,
pub app_port: u16,
pub session_secure_cookie: bool,
pub app_debug: bool,
pub app_url: String,
pub app_locale: String,
pub app_fallback_locale: String,
pub api_prefix: String,
pub mail_driver: String,
pub mail_host: String,
pub mail_port: u16,
pub mail_username: String,
pub mail_password: String,
pub mail_encryption: String,
pub mail_from_address: String,
pub mail_from_name: String,
pub cache_driver: String,
pub queue_driver: String,
pub log_channel: String,
pub log_level: String,
pub log_max_size: u64,
pub log_keep_files: u32,
pub deploy_type: String,
pub session_driver: String,
}Fields§
§app_name: String§app_env: String§app_port: u16Whether the session cookie carries the Secure attribute. Defaults
to true (safe over any real deployment). Browsers only treat
loopback addresses and the literal name localhost as secure
contexts over plain HTTP - a custom local dev hostname (e.g. a
.test domain resolved via /etc/hosts, even one that points at
127.0.0.1) is not on that list, so the Secure cookie is silently
dropped by the browser and sessions/CSRF stop working with no error
surfaced anywhere. Set SESSION_SECURE_COOKIE=false for that case.
app_debug: boolGates descriptive error pages (the full error message and source
chain, rendered as HTML) and panic details. Defaults to false -
safe if unset, so a deployment missing both .env and its own
config/app.rs’s APP_DEBUG handling never leaks internals by
accident. Scaffolded apps ship APP_DEBUG=true in their own
.env for local dev, mirroring Laravel’s own scaffold convention.
app_url: StringThe app’s own base URL, for larust_support::url()/asset() to
build absolute URLs from a relative path. Defaults to
"http://localhost" - matching Laravel’s own scaffolded default
exactly (no port; most local dev never needs url() to be
port-precise). Set APP_URL for anything that does.
app_locale: Stringlarust_lang::current_locale’s own default when no per-request
override is set (see that crate’s own doc comment) - Laravel’s
config('app.locale')/APP_LOCALE. Defaults to "en".
app_fallback_locale: Stringlarust_lang::t/t_with’s fallback when a key is missing from the
current locale’s own translation file - Laravel’s
config('app.fallback_locale')/APP_FALLBACK_LOCALE. Defaults to
"en", same as app_locale - most apps only
ever have one locale until they add a second, at which point this
is usually still the original one.
api_prefix: StringWhere routes/api.rs gets mounted (main.rs’s
.group(&config.api_prefix, ...) call) - Laravel’s own
routes/api.php is likewise served under a configurable prefix
(RouteServiceProvider’s apiPrefix), not a fixed one. Defaults to
"/api".
mail_driver: String"log" (default) writes a mail’s rendered subject/body to
tracing::info! instead of sending it - no network touched, no
SMTP server needed for local dev or cargo test, matching
Laravel’s own MAIL_MAILER=log scaffold default exactly. "smtp"
sends for real, using the fields below.
mail_host: String§mail_port: u16§mail_username: StringEmpty string means “unset” - Config has no Option<T> field
precedent elsewhere, and the log driver (the default) never
reads these anyway.
mail_password: String§mail_encryption: String§mail_from_address: String§mail_from_name: StringFalls back to app_name if unset, matching Laravel’s own
MAIL_FROM_NAME="${APP_NAME}" scaffold default.
cache_driver: String"database" (default) stores larust-cache’s entries in
cache_items, the same SQL-family table it has always used.
"redis" stores them in Redis instead - see larust-cache::store’s
own doc comment for the split. Same mail_driver-shaped “a plain
string picks a runtime code path” convention, not a typed enum:
larust-core has no sqlx/redis dependency and shouldn’t need
one just to name a driver.
queue_driver: Stringlarust-queue’s own driver toggle - see cache_driver’s
own doc comment for the shape and reasoning; independent of it
(an app can mix a database-backed cache with a Redis-backed queue,
or vice versa).
log_channel: String"stdout" (default) - everything goes to the terminal via
tracing_subscriber::fmt, exactly as before this field existed.
"file" writes to storage/logs/larust.log instead (rotated - see
log_max_size); "stack" writes to both, the
same “combine channels” meaning Laravel’s own LOG_CHANNEL=stack
has. Laravel additionally supports single/daily/slack/etc.
channels this doesn’t attempt - see crate::logging’s own module
doc comment for why size-based rotation was the one strategy
actually built.
log_level: StringEmpty string means “unset” (same convention as
mail_username) - falls back to this
crate’s own historical behavior: debug,sqlx=warn,tower_sessions=warn
in app_env == "local", info otherwise. Set to a plain level name
(trace/debug/info/warn/error) to override that for every
crate at once; sqlx/tower_sessions are still individually capped
at warn even then, for the same reason init_logging’s own
hardcoded default already did - see crate::logging’s doc comment.
RUST_LOG, if set, wins over this unconditionally, same as it
already won over the old hardcoded default.
log_max_size: u64Bytes - once storage/logs/larust.log reaches this size, it’s
rotated to larust.log.1 (shifting any existing .1/.2/… down
one) and a fresh, empty file is started. Only consulted when
log_channel is "file"/"stack". Defaults
to 10 MiB.
log_keep_files: u32How many rotated backups (larust.log.1 through larust.log.{N})
to keep before the oldest is deleted outright. 0 means “delete
immediately on rotation, keep only the current file.” Defaults to
5.
deploy_type: String"web" (default) - an ordinary server, deployed via xr deploy‘s
build-and-restart-handoff path. "app" - a Tauri desktop build,
where the app’s own Application/router is spawned in-process and
a native webview points at it locally instead of a browser
connecting over the network. Read by xr deploy/xr new (from
.env, not through this struct - see those crates’ own doc
comments for why), not by this crate itself; kept on Config
mainly so app code (e.g. a template wanting to render different
chrome for a desktop build) can read app.config().deploy_type
like any other setting.
session_driver: String"database" (default) - sessions live in whatever DB_CONNECTION
points at, via larust_http::session::AnySessionStore. "file" -
one file per session under storage/sessions/
(larust_http::session::FileSessionStore), Laravel’s own
SESSION_DRIVER=file equivalent: real persistence across a
restart/crash (unlike an in-memory store, which this framework
deliberately never offers - see larust_http::session’s own module
doc comment), just not through the app’s database. A genuinely
reasonable choice for a single-server app that would rather not put
session churn through its own database at all - see
docs/the-basics/middleware-sessions-and-csrf.md. Any other value
is treated the same as an unset LOG_CHANNEL (see that field’s own
doc comment on the identical “unrecognized degrades to the safe
default” precedent) - falls back to "database", but (unlike
LOG_CHANNEL) Application::new() warns about it first, since a
silently-ignored SESSION_DRIVER value was a real, reported
production confusion before that warning existed.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_value(value: &Value) -> Result<Self, AppError>
pub fn from_value(value: &Value) -> Result<Self, AppError>
Builds Config from value - the serde_json::Value an app’s own
generated config/app.rs (pub fn config() -> Value) produces. A
single serde_json::from_value call: Config already derives
Deserialize with a #[serde(default = ...)] per field, which
works identically regardless of the source Deserializer (this
used to be TOML, read from config/app.toml - see this crate’s
git history), so no manual field-by-field extraction is needed
here. Env-var override capability (Laravel’s own “config file sets
a default, .env can override it” behavior) lives entirely in the
generated config/app.rs’s own env_or/env_bool calls now -
this function has no knowledge of environment variables at all,
unlike the TOML-era load_from it replaced.