承接 geniusts/preferences 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

geniusts/preferences

最新稳定版本:2.4

Composer 安装命令:

composer require geniusts/preferences

包简介

Very easy way to generate a preferences page for applications that have multiple components and packages.

README 文档

README

This package to generate a preferences page to the application, specially if you have many component that have a different settings and you want to store it in the database and use it by default config functions of laravel.

Installation

  1. Download the package
  • command line:

composer require geniusts/preferences

  • or add it to composer file:
{
    "require": {
        "geniusts/preferences": "^2.0"
    }
}

and run: composer update

  1. Service Provider
  • If you are using Laravel >=5.5 and the auto-discover is enabled, no need to do anything.
  • If your Laravel <5.5 or you disabled auto-discover add the ServiceProvider to the providers array in config/app.php
    GeniusTS\Preferences\PreferencesServiceProvider::class,

Note: If you are using Laravel 5.5 or greater no need to add it, It will auto discove

  1. Controller And Migrations

Publish the package Controller file to your application. Run these commands:

php artisan vendor:publish --provider="GeniusTS\Preferences\PreferencesServiceProvider" --tag=controller

You can also publish views and migrations by the following commands:

php artisan vendor:publish --provider="GeniusTS\Preferences\PreferencesServiceProvider" --tag=views
php artisan vendor:publish --provider="GeniusTS\Preferences\PreferencesServiceProvider" --tag=migrations

No need to publish the migrations files just run migrate command to execute the migrations.

php artisan migrate

If you want to use DB transaction while saving the data, add protected $transactions = true; to SettingsController.

  1. Routes and views

Add two routes to you routes file:

Route::get('/settings/{preferences_domain?}', 'SettingsController@edit')
    ->midllware(//Apply your middleware)
    
Route::patch('/settings/{preferences_domain?}/{preferences_element?}', 'SettingsController@update')
    ->midllware(//Apply your middleware)

Now you have to create a preferences.settings view with your app layout and include the geniusts_preferences::settings view.

@include('geniusts_preferences::settings');

Usage

Creating settings tab

  1. create a view of the settings: Ex.: settings/general.blade.php
    <div class="row">
        <div class="col-xs-12">
            <div class="form-group">
                <label> Test </label>
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="glyphicon glyphicon-alert"></i>
                    </div>
    
                    <input class="form-control" 
                           name="general[project_name]"
                           value="{{ old('general.project_name', config('preferences.general.project_name')) }}">
                </div>
            </div>
        </div>
    </div>
  1. Register the tab to PreferencesManager
    use GeniusTS\Preferences\Models\Domain;
    use GeniusTS\Preferences\Models\Element;
    
    // Create a settings Domain
    // Domain(string $key, View $view, string $label)
    // you can use label like 'labels.general', because the view execute "trans" function
    $domain = new Domain('general', view('settings.general'), 'General');
    
    // Add the inputs names and validation rules
    // Element(string $name, mixed $rules)
    $domain->addElement(new Element('project_name', 'required|max:255'));
    
    // OR for array values
    $domain->addElement(new Element('options', ['options' => 'array', 'options.*' => 'required|integer']));
    
    
    // register the Domain to the Preferences manager
    $manager = resolve('preferences'); // or app('preferences') for versions older than 5.3
    $manager->addDomain($domain);

You can register the domains in the boot function of your package service provider.

Access saved settings

Use the default config function or Config class to get the values of your settings: config('preferences.{domain}.{element}')

config('preferences.general.project_name');

Migration from version 1

  1. update inputs name inside preferences views. Ex: You have a general domain that have project_name element, then the input name should be general[project_name].

  2. Update declaration of edit and handleSuccessResponse methods of SettingsController inside your project.

   public function edit($domain = null) {
        // Logic here
   }
       
    protected function handleSuccessResponse($domain, $element) {
        // Logic here    
    }

License

This package is free software distributed under the terms of the MIT license.

geniusts/preferences 适用场景与选型建议

geniusts/preferences 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.25k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Settings」 「configurations」 「preferences」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 geniusts/preferences 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-09