定制 symkit/settings-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

symkit/settings-bundle

Composer 安装命令:

composer require symkit/settings-bundle

包简介

A Symfony bundle for managing application-wide settings with a sectioned UI, automatic cache invalidation, and WebManifest generation.

README 文档

README

CI Latest Version PHPStan Level 9

A Symfony bundle for managing application-wide settings with a sectioned UI, automatic cache invalidation, and WebManifest generation. Features are activable per block (admin, webmanifest, Twig, metadata provider). Entity and repository are configurable so you can use your own classes.

Requirements

  • PHP 8.2+
  • Symfony 7.x or 8.x
  • symkit/media-bundle (for Media fields and entity relations)
  • symkit/form-bundle, symkit/crud-bundle, symkit/metadata-bundle, symkit/menu-bundle (for the admin UI)

Features

  • Sectioned Form: Organize settings into logical groups (General, Logos, Social, Icons) via FormSectionType (symkit/form-bundle).
  • Singleton Management: Single settings entity with cache and invalidation on update.
  • WebManifest: Service to generate site.webmanifest data; route can be enabled/disabled.
  • Twig: Global settings variable and app_settings() function (optional).
  • Metadata: Optional SiteInfoProvider for symkit/metadata-bundle.
  • Translations: Domain SymkitSettingsBundle with EN and FR provided.

Installation

  1. Install the bundle:

    composer require symkit/settings-bundle
  2. Register the bundle in config/bundles.php:

    return [
        // ...
        Symkit\SettingsBundle\SettingsBundle::class => ['all' => true],
    ];
  3. Configure Doctrine mapping in config/packages/doctrine.yaml (adjust dir/prefix if using a custom entity):

    doctrine:
        orm:
            mappings:
                Settings:
                    type: attribute
                    is_bundle: false
                    dir: '%kernel.project_dir%/vendor/symkit/settings-bundle/src/Entity'
                    prefix: 'Symkit\SettingsBundle\Entity'
                    alias: Settings
  4. Create config/packages/symkit_settings.yaml:

    symkit_settings:
        cache_expires_after: 86400
        admin:
            enabled: true
            route_prefix: admin
        webmanifest:
            enabled: true
        twig:
            enabled: true
        metadata_provider:
            enabled: true
        doctrine:
            entity: Symkit\SettingsBundle\Entity\Settings
            repository: Symkit\SettingsBundle\Repository\SettingsRepository
  5. Routes: Import only the route files for features you enable.

    • If admin.enabled is true, in config/routes.yaml:
      symkit_settings_admin:
          resource: '@SymkitSettingsBundle/config/routes_admin.yaml'
          prefix: '/%symkit_settings.admin.route_prefix%'
    • If webmanifest.enabled is true:
      symkit_settings_webmanifest:
          resource: '@SymkitSettingsBundle/config/routes_webmanifest.yaml'
  6. Metadata (optional)
    If metadata_provider.enabled is true, set your app’s metadata bundle to use the settings provider, e.g. in config/packages/symkit_metadata.yaml:

    symkit_metadata:
        site_info_provider: Symkit\SettingsBundle\Provider\SettingsSiteInfoProvider

Configuration

Option Type Default Description
cache_expires_after int 86400 Cache TTL in seconds.
admin.enabled bool true Register admin controller and admin routes.
admin.route_prefix string admin URL prefix for admin (e.g. /admin/settings).
webmanifest.enabled bool true Register webmanifest controller and route.
twig.enabled bool true Register Twig extension (settings, app_settings()).
metadata_provider.enabled bool true Register SiteInfoProvider for symkit/metadata-bundle.
doctrine.entity string Symkit\SettingsBundle\Entity\Settings FQCN of settings entity.
doctrine.repository string Symkit\SettingsBundle\Repository\SettingsRepository FQCN of settings repository.

Disabling a feature (e.g. admin.enabled: false) means the corresponding services and routes are not registered; do not import the related route file in that case.

Custom entity and repository

Your entity must implement Symkit\SettingsBundle\Contract\SettingsInterface. Your repository must implement Symkit\SettingsBundle\Contract\SettingsRepositoryInterface and provide a constructor compatible with the bundle (e.g. ManagerRegistry + string $entityClass for a Doctrine repository).

Example:

symkit_settings:
    doctrine:
        entity: App\Entity\MySettings
        repository: App\Repository\MySettingsRepository

Map your entity in Doctrine and import only the admin route if you use the bundled admin UI.

Usage

Twig (when twig.enabled is true)

{{ settings.websiteName }}
{% set app_settings = app_settings() %}
{{ app_settings.websiteDescription }}

PHP

Inject the manager interface:

use Symkit\SettingsBundle\Contract\SettingsManagerInterface;

public function __construct(
    private SettingsManagerInterface $settingsManager,
) {}

public function someMethod(): void
{
    $settings = $this->settingsManager->get();
}

WebManifest

When webmanifest.enabled is true and the route is imported, the manifest is served at /site.webmanifest.

Translations

The bundle uses the domain SymkitSettingsBundle and ships with translations/SymkitSettingsBundle.en.xlf and SymkitSettingsBundle.fr.xlf. You can override or add messages in your app’s translations/ directory with the same domain.

Contributing

Run make quality before committing.

License

MIT.

symkit/settings-bundle 适用场景与选型建议

symkit/settings-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 symkit/settings-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 symkit/settings-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 symkit/settings-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-22