fm-labs/cakephp-settings
Composer 安装命令:
composer require fm-labs/cakephp-settings
包简介
Settings plugin for CakePHP
README 文档
README
Store configuration settings in database.
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
$ composer require fm-labs/cakephp-settings:^5
# For CakePHP 4.x
$ composer require fm-labs/cakephp-settings:^4
Run migrations
$ ./bin/cake migrations migrate --plugin Settings
Usage
Manage settings via Console
// Initialize settings from schema $ ./bin/cake settings init // List available settings $ ./bin/cake settings list // List configured settings values $ ./bin/cake settings values // Get setting value $ ./bin/cake settings get-value // Update setting value $ ./bin/cake settings set-value
Manage settings programmatically
@TODO
Load settings
To load settings for your app:
// In your bootstrap.php or in Plugin::bootstrap() \Cake\Core\Configure::load('app', 'settings');
To load plugin settings:
// In your bootstrap.php or in Plugin::bootstrap() \Cake\Core\Configure::load('PluginName', 'settings');
Settings Schema file
App and plugin settings are defined in settings schema file, which should be in your app's or plugins's config directory.
APP/config/settings.php or PLUGINS/MyPlugin/config/settings.php respectively.
<?php // Example settings.php for User plugin return [ 'Settings' => [ 'User' => [ 'groups' => [ 'User.Auth' => ['label' => __('User Authentication')], 'User.Signup' => ['label' => __('User Signup')], ], 'schema' => [ 'User.Login.disabled' => [ 'group' => 'User.Auth', 'type' => 'boolean', 'default' => true, ], 'User.Signup.disabled' => [ 'group' => 'User.Signup', 'type' => 'boolean', 'default' => true, ], 'User.Signup.verifyEmail' => [ 'group' => 'User.Signup', 'type' => 'boolean', 'default' => false, ], ], ], ], ];
Events
The Settings.build event will be triggered, when the global settings schema gets initialized.
/** * */ public function implementedEvents() { return [ 'Settings.build' => 'buildSettings', ]; } /** * @param \Cake\Event\Event $event The event object * @param \Settings\Settings $settings The settings object * @return void */ public function buildSettings(Event $event, $settings) { // load a settings schema config file //$settings->load('User.settings'); // add a setting group $settings->addGroup('User.Password', [ 'label' => 'User Password Settings' ]); // add a setting $settings->add('User.Password.expireInDays', [ 'group' => 'User.Password', 'type' => 'int', 'label' => 'Password expiry (in days)', 'help' => 'The password will expire in X days and a new password needs to be entered by the user at the next login.' ]); }
fm-labs/cakephp-settings 适用场景与选型建议
fm-labs/cakephp-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 189 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fm-labs/cakephp-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fm-labs/cakephp-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 189
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 2
- 推荐数: 3
其他信息
- 授权协议: Unknown
- 更新时间: 2020-12-01