merodiro/settings
Composer 安装命令:
composer require merodiro/settings
包简介
Easy global/user settings
README 文档
README
laravel easy key => value global/user settings
Install
Via Composer
$ composer require merodiro/settings
publish config through Optional: only if you want to edit cache configurations
$ php artisan vendor:publish --provider=Merodiro\Settings\SettingsServiceProvider
Setup a Model
use Merodiro\Settings\HasSettings; class User extends Model { use HasSettings; ... }
Usage
Set settings
creates a record if the key doesn't exist or update it if the key exists
in addition to updating the cache
// Global Settings Settings::set('key', 'value'); Settings::set('key', 'another value'); // User Settings $user->setSettings('key', 'value'); $user->setSettings('key', 'another value');
Get value from settings
Returns its value if it exists or the second parameter if it doesn't exist
// Global Settings $name = Settings::get('site-name'); $value = Settings::get('key', 'default'); // User Settings $user->getSettings('site-name'); $user->getSettings('key', 'value');
Delete key from settings
Remove the setting with the given key in addition to removing it from the cache
// Global Settings Settings::forget('key'); // User Settings $user->forgetSettings('key');
Delete all settings
Delete all the settings in addition to removing them from the cache
// Global Settings Settings::flush(); // User Settings $user->flushSettings();
Get all settings
Returns all settings stored in key => value array
// Global Settings $settings = Settings::all(); // User Settings $settings = $user->allSettings();
Artisan Commands
Cache all settings
Caches all settings for the duration that has been set in settings.php config file
you can set the duration to a high number or schedule the command to run often to get the best value of it
# Global settings only php artisan settings:cache # Global and User Settings php artisan settings:cache --model=App/User
Clear cache for all settings
# Global settings only $ php artisan settings:clear # Global and User Settings $ php artisan settings:clear --model=App/User
Blade Directives
Get value from blade template
<h1>@settings('site-name')</h1> <h1>@settings('site-name', 'default name')</h1>
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security-related issues, please email merodiro@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
merodiro/settings 适用场景与选型建议
merodiro/settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.71k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2017 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Settings」 「Merodiro」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 merodiro/settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 merodiro/settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 merodiro/settings 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Persistent settings package for Laravel framework.
A Zend Framework module to quickly and easily set PHP settings.
Settings Card for Laravel Nova.
Extends basic Wordpress features.
Settings Manager
Advanced configuration manager for PHP with dotted-path access, file/directory/class loaders and a static facade.
统计信息
- 总下载量: 2.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 35
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-23