承接 quorae/settings-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

quorae/settings-bundle

最新稳定版本:v1.0.1

Composer 安装命令:

composer require quorae/settings-bundle

包简介

YAML-defined runtime settings with DB overrides, encryption, caching, validation, and a Live Component admin UI for Symfony 7+.

README 文档

README

YAML-defined runtime settings with DB overrides, libsodium encryption, cache, validation, and a Live Component admin UI for Symfony 7+.

Features

  • YAML definitions — declare settings groups in config/settings/*.yaml with typed fields, labels, descriptions, defaults, validation rules, and choices
  • DB overrides — override any default at runtime via a setting_overrides table (only stores diffs from defaults)
  • Encryption — fields marked encrypted: true are stored with libsodium authenticated encryption (XSalsa20-Poly1305), key derived from APP_SECRET via HKDF
  • Env var resolution — defaults can be sourced from environment variables (env_key:) or files (file://)
  • Cache — resolved groups are cached via TagAwareCacheInterface with per-request memoization
  • Validation — explicit constraints from YAML (NotBlank, Length, Range, Choice, Regex, Type, Email, Url) + implicit shape guards per field type
  • Live Component editor — drop-in <twig:QuoraeSettings:Editor group="my_group" /> with per-field rendering, masked passwords, reset-to-default, flash messages
  • CLI commandsquorae:settings:list, quorae:settings:cache, quorae:settings:clear, quorae:settings:check-encryption
  • Multi-DB support — repository uses platform-aware upsert (PostgreSQL, MySQL/MariaDB, generic fallback)

Installation

composer require quorae/settings-bundle

Register the bundle (auto-discovered by Symfony Flex):

// config/bundles.php
return [
    // ...
    Quorae\SettingsBundle\QuoraeSettingsBundle::class => ['all' => true],
];

Database

Run bin/console doctrine:schema:update --force or create a migration for the setting_overrides table. The entity is mapped via Doctrine ORM attributes.

Cache

The bundle uses cache.app.taggable. Make sure your Symfony app has a tag-aware cache pool configured (default in Symfony 7).

Configuration

# config/packages/quorae_settings.yaml
quorae_settings:
    definitions_path: config/settings          # relative to %kernel.project_dir%
    scope: global                              # only allowed scope (V1)
    allowed_env_prefixes: ['AI_', 'MAILER_']   # restrict env_key usage (empty = all allowed)
    allowed_file_prefixes: ['docs/prompts/']   # restrict file:// defaults (empty = all allowed)
    encryption:
        hkdf_info: my-app-settings             # HKDF context — change to isolate from other apps

Defining a settings group

Create a YAML file in config/settings/:

# config/settings/mailer.yaml
group: mailer
group_label: "Mail configuration"
scope: global
order: 100

fields:
  host:
    type: text
    label: "SMTP host"
    default: "smtp.example.com"
    rules:
      - NotBlank: ~

  port:
    type: integer
    label: "SMTP port"
    default: 587
    rules:
      - Range: { min: 1, max: 65535 }

  password:
    type: password
    label: "SMTP password"
    encrypted: true
    env_key: MAILER_PASSWORD

  use_tls:
    type: boolean
    label: "Use TLS"
    default: true

  provider:
    type: choice
    label: "Provider"
    default: smtp
    choices:
      smtp: "SMTP direct"
      sendgrid: "SendGrid API"
      ses: "Amazon SES"

Field types

text, textarea, choice, boolean, integer, float, password, markdown

Default resolution priority

env_key > file:// > literal default

Reading settings

use Quorae\SettingsBundle\Contract\SettingsReaderInterface;

final readonly class MyService
{
    public function __construct(
        private SettingsReaderInterface $settings,
    ) {}

    public function doSomething(): void
    {
        $host = $this->settings->getValue('mailer', 'host');
        $group = $this->settings->getGroup('mailer');
        $port = $group->port; // magic __get
    }
}

Admin UI (Live Component)

Requires symfony/ux-live-component and symfony/ux-twig-component.

{# In any Twig template #}
<twig:QuoraeSettings:Editor group="mailer" />

Templates are overridable via standard Symfony mechanism:

templates/bundles/QuoraeSettingsBundle/components/QuoraeSettings/SettingsEditor.html.twig

The component has no authorization by default. Protect it in your app:

  • Use #[IsGranted] on your controller
  • Or extend the component class and add #[IsGranted('ROLE_ADMIN')]

CLI Commands

bin/console quorae:settings:list                     # show all resolved values
bin/console quorae:settings:list --group=mailer       # single group
bin/console quorae:settings:cache                     # warm cache
bin/console quorae:settings:clear                     # purge cache
bin/console quorae:settings:check-encryption          # verify encrypted fields

License

MIT

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固