Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created August 21, 2024 11:17
Show Gist options
  • Save ziadoz/d28fa6cab5bc9836493c409cd49f2f28 to your computer and use it in GitHub Desktop.
Save ziadoz/d28fa6cab5bc9836493c409cd49f2f28 to your computer and use it in GitHub Desktop.
Pydantic Settings for PHP
<?php
// @see: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#usage
final readonly class DatabaseConfig
{
#[Concat(
#[Env('DB_HOST')],
#[Str('://')],
#[Env('DB_USER')],
#[Str('@')],
#[Env('DB_PASS', secret: true)] // Adds #[SensitiveParameter]???
)]
public string $dsn;
}
final readonly class AppConfig
{
// Assumed from APP_NAME
public string $appName;
#[Env('APP_TIMEZONE')];
public string $appTimezone;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment