parabellumkoval/backpack-settings
Composer 安装命令:
composer require parabellumkoval/backpack-settings
包简介
Settings UI & Service for Laravel 8 + Backpack 4.1 (config/DB drivers, tabs, registry, aliases).
README 文档
README
Settings UI & Service for Laravel 8 + Backpack 4.1.
- Use base Backpack fields and add custom fields.
- Define settings via a Class Registrar (separate from providers).
- Tabs support per page (and per field via
tab()). - DB + Config drivers, with DB override.
- Simple facade:
Settings::get('some.key')/Settings::set(...).
Install
composer require parabellumkoval/backpack-settings php artisan vendor:publish --provider="Backpack\Settings\Providers\BackpackSettingsServiceProvider" --tag=config php artisan vendor:publish --provider="Backpack\Settings\Providers\BackpackSettingsServiceProvider" --tag=migrations php artisan migrate
Register your settings via Class Registrar
Create a class in your package/app, e.g. App\Settings\StoreSettingsRegistrar.php:
<?php namespace App\Settings; use Backpack\Settings\Contracts\SettingsRegistrarInterface; use Backpack\Settings\Services\Registry\Registry; use Backpack\Settings\Services\Registry\Field; class StoreSettingsRegistrar implements SettingsRegistrarInterface { public function register(Registry $registry): void { $registry->group('store', function ($group) { $group->title('Магазин')->icon('la la-store') ->page('Общее', function ($page) { $page->add(Field::make('store.products.modifications.enabled', 'checkbox') ->label('Включить модификации') ->default(false) ->cast('bool') ->tab('Основное') ); $page->add(Field::make('store.products.modifications.mode', 'select') ->label('Режим модификаций') ->options(['vertical' => 'Вертикальные', 'flat' => 'Плоские']) ->default('vertical') ->cast('string') ->tab('Расширенные') ); }) ->page('Оплата', function ($page) { $page->add(Field::make('store.payment.cod_enabled', 'toggle') ->label('Наложенный платеж') ->default(true) ->cast('bool') ); }); }); } }
Then reference it in config/backpack-settings.php:
'registrars' => [ App\Settings\StoreSettingsRegistrar::class, ],
Alternatively, in your package service provider: resolve and call your registrar manually
(still keeps your settings definition in a dedicated class).
Admin UI
Visit: /admin/settings/store
- The page is split into tabs by pages (Общее, Оплата).
- Inside a page, you can further segment fields by setting
->tab('...').
Access values in code
use Backpack\Settings\Facades\Settings; if (Settings::get('store.products.modifications.enabled')) { // ... }
Add custom fields
Put blade views under resources/views/vendor/backpack-settings/fields/yourtype.blade.php
or ship them within this package's resources/views/fields.
Then, in your registrar, use Field::make('key', 'yourtype').
Locale & Region aware settings
Settings can now be scoped by locale (language) and/or region.
- Mark a field as locale-specific with
->translatable(true). - Mark a field as region-specific with
->regionable(true). - Combine both for values that depend on country and language.
The admin UI shows switchers for the configured locales/regions, so editors can toggle between variations. Values are stored per combination and fall back automatically: region + locale → region → locale → default.
Expose available options via config/backpack-settings.php:
return [ 'available_locales' => ['en' => 'English', 'ru' => 'Русский'], 'available_regions' => ['de' => 'Germany', 'pl' => 'Poland'], 'locale_query_parameter' => 'locale', 'region_query_parameter' => 'country', ];
The public API endpoints automatically respect the context:
GET /api/settings/nested?country=dewill prefer region-specific values.- The
Accept-Languageheader (or explicit?locale=) drives the locale fallback chain.
## License
MIT
parabellumkoval/backpack-settings 适用场景与选型建议
parabellumkoval/backpack-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 223 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 08 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 parabellumkoval/backpack-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 parabellumkoval/backpack-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 223
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-02