pxpm/backpack-crud-settings
Composer 安装命令:
composer require pxpm/backpack-crud-settings
包简介
Allow developers to add settings into CRUD
README 文档
README
Create settings dashboards to your Backpack application.
Instalation:
composer require pxpm/backpack-crud-settings
- Migrate the settings table:
php artisan db:migrate
Publish the config file
php artisan vendor:publish --provider="Pxpm\BpSettings\BpSettingsServiceProvider" --tag=config
Create a seeder that will seed your settings into database:
php artisan make:seeder SettingsSeeder
IMPORTANT NOTE
This seeder will be the only source of truth for your settings. This is the way you can add/delete/update settings from database.
The above command will generate something like this in your Database\Seeds\ folder by default in Laravel application.
<?php use Illuminate\Database\Seeder; class SettingsSeeder extends Seeder { public function run() { //create your array of settings like defining Backpack fields. $settings = [ [ 'name' => 'company_name', 'type' => 'text', 'label' => 'Company Name', 'tab' => 'Main', 'wrapperAttributes' => ['class' => 'col-md-6 form-group'] ] ]; //call the setting manager to manage those settings. It will take care of create/update/delete settings. app('settingsmanager')->create($settings); }
NOTES:
-
After creating your seeder you should
composer dump-autoload -
Seed the settings with:
php artisan db:seed --class=SettingsSeeder
Configuration
If you follow all the instalation steps you should now have an bpsettings.php file in your config/ directory. The default config is ready to work out-of-box, but you are free to customize it the way you want.
Creating settings
You can now access your settings panel in:
your_url.com/backpack_admin_prefix/bp-settings
To add settings to your panels like described above you should create an array of Backpack fields and pass them to the Settings Manager.
There are some key points in setting definition that you can use to better organize your setting panels.
namespace
By default the settings namespace is null, that means it's a general setting and will appear in the main settings panel. By defining settings namespaces you can create aditional setting panels.
If you setup some settings with namespace => 'users' those settings will be available separately in: your_url.com/backpack_admin_prefix/bp-settings/users
group
Allow you to group settings further inside the panel. You can use tab provided in Backpack with conjunction with group.
validation
You can validate your settings inputs using regular laravel validation.
Define the key validation => 'required|min:5' and we will run your setting input against the laravel validator and return any errors found.
Using settings
- All settings are pushed into config array on run-time. We use cache mechanism to make sure we don't query the database if there are no changes to settings and just grab the cached version.
You can get the values of non namespaced settings with: config('bpsettings.setting_name) or app('settingsmanager)->get('setting_name')
To get namespaced setting value you can do it with: config('bpsettings.namespace.setting_name) or app('settingsmanager)->get('namespace.setting_name')
IMPORTANT NOTE:
This is still a work in progress, i cannot guarantee 100% flawless work.
pxpm/backpack-crud-settings 适用场景与选型建议
pxpm/backpack-crud-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 89 次下载、GitHub Stars 达 8, 最近一次更新时间为 2020 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「admin」 「laravel」 「Settings」 「backpack」 「pxpm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pxpm/backpack-crud-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pxpm/backpack-crud-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pxpm/backpack-crud-settings 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Persistent settings package for Laravel framework.
2lenet/EasyAdminPlusBundle
A Zend Framework module to quickly and easily set PHP settings.
Settings Card for Laravel Nova.
Analysis module for finding problematical shop data.
Extends basic Wordpress features.
统计信息
- 总下载量: 89
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-22