承接 gathercontent/config-value-object 相关项目开发

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

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

gathercontent/config-value-object

最新稳定版本:0.2.4

Composer 安装命令:

composer require gathercontent/config-value-object

包简介

Validate item config for GatherContent

README 文档

README

Build Status

Ensure the config adheres to the rules.

Requirements

  • PHP 5.3.0 or later (recommend at least PHP 7.1)

Installation

Run the following command inside your repository:

$ composer require gathercontent/config-value-object:0.2.*

Usage

$json = 'your config in JSON format goes here!';

$configObject = Config::fromJson($json);

The code above will throw ConfigValueException if the config does not adhere to the rules.

The rules

The config is an array of tabs. It must have at least one tab.

An example of valid config:

[
  {
    "label": "Content",
    "name": "tab1",
    "hidden": false,
    "elements": [
      {
        "type": "text",
        "name": "el1",
        "required": false,
        "label": "Blog post",
        "value": "<p>Hello world</p>",
        "microcopy": "",
        "limit_type": "words",
        "limit": "1000",
        "plain_text": false
      }
    ]
  }
]

Tab structure:

Must be an object. All attributes are required. No additional attributes are allowed.

{
  "label": "Content",                // string, not empty
  "name": "tab1",                    // string, not empty, unique
  "hidden": false,                   // boolean
  "elements": [ /* tab elements */ ] // array
}

Element structure

Allowed element types:

  • text
  • files
  • section
  • choice_radio
  • choice_checkbox

All elements must be objects. All attributes are required. No additional attributes are allowed.

Type text:
{
  "type": "text",                // string, must be "text"
  "name": "el1",                 // string, not empty, unique
  "required": false,             // boolean
  "label": "Blog post",          // string, not empty
  "value": "<p>Hello world</p>", // string
  "microcopy": "",               // string
  "limit_type": "words",         // string, either "words" or "chars"
  "limit": 1000,                 // integer, non-negative
  "plain_text": false            // boolean
}
Type files:
{
  "type": "files",   // string, must be "files"
  "name": "el2",     // string, not empty, unique
  "required": false, // boolean
  "label": "Photos", // string, not empty
  "microcopy": ""    // string
}
Type section:
{
  "type": "section",                 // string, must be "section"
  "name": "el3",                     // string, not empty, unique
  "title": "Title",                  // string, not empty
  "subtitle": "<p>How goes it?</p>"  // string
}
Type choice_radio:
{
  "type": "choice_radio",              // string, must be "choice_radio"
  "name": "el4",                       // string, not empty, unique
  "required": false,                   // boolean
  "label": "Label",                    // string, not empty
  "microcopy": "",                     // string
  "other_option": false,               // boolean
  "options": [ /* element options */ ] // array, must have at least one option
}

At least two options required if other_option is true.

Type choice_checkbox:
{
  "type": "choice_checkbox",           // string, must be "choice_checkbox"
  "name": "el4",                       // string, not empty, unique
  "required": false,                   // boolean
  "label": "Label",                    // string, not empty
  "microcopy": "",                     // string
  "options": [ /* element options */ ] // array, must have at least one option
}

Option structure

All options must be objects. All attributes are required. No additional attributes are allowed.

Most options will look like this:

{
  "name": "op1",       // string, not empty, unique
  "label": "Option 1", // string, not empty
  "selected": false    // boolean
}

The only exception is the last option for choice_radio element if the other_option attribute is true:

{
  "name": "op1",       // string, not empty, unique
  "label": "Other",    // string, not empty
  "selected": true,    // boolean
  "value": "Something" // string
}

The value attribute for "other" option must be empty if the option is not selected.

choice_radio must not have more than one option selected.

Testing

Run unit tests:

$ ./vendor/bin/phpunit

Test compliance with PSR2 coding style guide:

$ ./vendor/bin/phpcs --standard=PSR2 ./src

gathercontent/config-value-object 适用场景与选型建议

gathercontent/config-value-object 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63.66k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 gathercontent/config-value-object 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 14
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-24