可编程 可扩展安全的 配置

bird.pkl
name = "Swallow"

job {
  title = "Sr. Nest Maker"
  company = "Nests R Us"
  yearsOfExperience = 2
}

{
  "name": "Swallow",
  "job": {
    "title": "Sr. Nest Maker",
    "company": "Nests R Us",
    "yearsOfExperience": 2
  }
}

生成任何静态配置格式

将所有数据定义为Pkl,并生成JSON、YAML、属性列表和其他配置格式的输出。

应用集成配置

将 Pkl 嵌入到您的应用程序中以进行运行时配置,并接收 Java、Kotlin、Swift 和 Go 的代码生成。

java logo kotlin logo swift logo go logo

module example.MyAppConfig

/// The hostname for the application
host: String

/// The port to listen on
port: UInt16(this > 1000)
intellij

令人难以置信的IDE集成

为以与静态类型语言相同的简便性编写 Pkl 提供了出色的工具。我们为 IntelliJ、Visual Studio Code 和 Neovim 提供插件和扩展,并且还提供 PKL Language Server ,以便您可以轻松地进行自己的编辑器集成。

部署前捕捉错误

通过丰富的类型和验证系统,在部署应用程序之前捕获配置错误。

email: String = "dev-team@company.com"

port: Int(this > 1000) = 80

–– Pkl Error ––
Type constraint `this > 1000` violated.
Value: 80

3 | port: Int(this > 1000) = 80
              ^^^^^^^^^^^
at config#port (config.pkl, line 3)

3 | port: Int(this > 1000) = 80
                             ^^
at config#port (config.pkl, line 3)

106 | text = renderer.renderDocument(value)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^