PHPackages                             gatherpackages/config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. gatherpackages/config

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

gatherpackages/config
=====================

Validate item config for GatherContent

1.3.1(4y ago)097.9k↓50%PHPPHP &gt;=7.3

Since Aug 21Pushed 4y ago5 watchersCompare

[ Source](https://github.com/gathercontent/config)[ Packagist](https://packagist.org/packages/gatherpackages/config)[ RSS](/packages/gatherpackages-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (15)Used By (0)

Config Value Object
===================

[](#config-value-object)

[![Build Status](https://camo.githubusercontent.com/371e2e90cfdd680d2fc950267fd09ddb77be270ad100cda4af5469d4c2245101/68747470733a2f2f7472617669732d63692e6f72672f676174686572636f6e74656e742f636f6e6669672e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/gathercontent/config)

Ensure the config adheres to [the rules](#the-rules).

Requirements
------------

[](#requirements)

- PHP 7.3 or later

Installation
------------

[](#installation)

Run the following command inside your repository:

```
$ composer require gatherpackages/config:1.*
```

Usage
-----

[](#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 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": "Hello world",
        "microcopy": "",
        "limit_type": "words",
        "limit": "1000",
        "plain_text": false
      }
    ]
  }
]
```

#### Tab structure:

[](#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

[](#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)

```
{
  "type": "text",                // string, must be "text"
  "name": "el1",                 // string, not empty, unique
  "required": false,             // boolean
  "label": "Blog post",          // string, not empty
  "value": "Hello world", // string
  "microcopy": "",               // string
  "limit_type": "words",         // string, either "words" or "chars"
  "limit": 1000,                 // integer, non-negative
  "plain_text": false            // boolean
}
```

##### Type `files`:

[](#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)

```
{
  "type": "section",                 // string, must be "section"
  "name": "el3",                     // string, not empty, unique
  "title": "Title",                  // string, not empty
  "subtitle": "How goes it?"  // string
}
```

##### Type `choice_radio`:

[](#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)

```
{
  "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

[](#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
-------

[](#testing)

Run unit tests:

```
$ ./vendor/bin/phpunit
```

Test compliance with [PSR2 coding style guide](http://www.php-fig.org/psr/psr-2/):

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

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~198 days

Recently: every ~41 days

Total

12

Last Release

1739d ago

Major Versions

0.2.4 → 1.0.02021-02-26

PHP version history (2 changes)0.1.0PHP &gt;=5.3.0

1.0.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd4d11f77ff189af7261895fd7dac86189e7827fda2923ea4a7597ff2f702218?d=identicon)[HughbertD](/maintainers/HughbertD)

![](https://avatars.githubusercontent.com/u/825428?v=4)[Richard Bagshaw](/maintainers/bagwaa)[@bagwaa](https://github.com/bagwaa)

![](https://www.gravatar.com/avatar/db5fa89ee90e3238b83d0c27e7540e3ba7bdbceee4a037d52480b1a2a9aabab0?d=identicon)[smallneat](/maintainers/smallneat)

![](https://www.gravatar.com/avatar/794a247d9359cc23443d7c17cdf09252b3cf9dc6630254d51fb712a51db8e477?d=identicon)[petemcfarlane](/maintainers/petemcfarlane)

---

Top Contributors

[![lukerenfrew](https://avatars.githubusercontent.com/u/6362725?v=4)](https://github.com/lukerenfrew "lukerenfrew (12 commits)")[![petemcfarlane](https://avatars.githubusercontent.com/u/3472717?v=4)](https://github.com/petemcfarlane "petemcfarlane (5 commits)")[![acairns](https://avatars.githubusercontent.com/u/705212?v=4)](https://github.com/acairns "acairns (4 commits)")[![legierski](https://avatars.githubusercontent.com/u/1420343?v=4)](https://github.com/legierski "legierski (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gatherpackages-config/health.svg)

```
[![Health](https://phpackages.com/badges/gatherpackages-config/health.svg)](https://phpackages.com/packages/gatherpackages-config)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)[xemlock/htmlpurifier-html5

HTML5 support for HTML Purifier

1052.9M11](/packages/xemlock-htmlpurifier-html5)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
