Created
August 21, 2024 11:17
-
-
Save ziadoz/d28fa6cab5bc9836493c409cd49f2f28 to your computer and use it in GitHub Desktop.
Pydantic Settings for PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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