PHPackages                             codexsoft/transmission-schema - 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. codexsoft/transmission-schema

ActiveLibrary

codexsoft/transmission-schema
=============================

Schema configuration, validation and normalization part of CodexSoft Transmission PHP Library for building HTTP JSON API

v2.0.3(4y ago)0123↑1400%3MITPHPPHP ^8

Since Oct 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/codexsoft/transmission-schema)[ Packagist](https://packagist.org/packages/codexsoft/transmission-schema)[ RSS](/packages/codexsoft-transmission-schema/feed)WikiDiscussions release/2.x Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (24)Used By (3)

CodexSoft Transmission
======================

[](#codexsoft-transmission)

Compact extendable library to build HTTP API based on JSON.

Provides normalization and validation features based on top of [symfony/validator](https://symfony.com/doc/current/components/validator.html) component.

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

[](#installation)

```
composer require codexsoft/transmission
```

Why
---

[](#why)

Suppose we have incoming data like this in our controller:

```
$input = [
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'pets' => [
        [
            'kind' => 42,
            'name' => 'Rex',
        ],
        [
            'kind' => 34,
            'name' => 'Sunny',
        ]
    ],
];
```

- How will we check that `pets` present in `$input`?
- How will we check that `name` is not empty or contains at least 3 symbols?
- How will we check that `email` is formally correct?
- How will we check that `pets` has at least one pet?
- How will we check that `pets[n].kind` contains one of allowed values (15, 34, 42)?
- How will we handle these violations and generate error response?

This library allows to do this:

```
use CodexSoft\Transmission\Schema\Accept;

$schema = Accept::json([
    'name' => Accept::string()->minLength(3),
    'email' => Accept::email(),
    'pets' => Accept::collection(
        Accept::json([
            'kind' => Accept::integer()->choices([15, 34, 42]),
            'name' => Accept::string(),
        ])
    ),
]);

$result = $schema->validateNormalizedData($userInput);
if ($result->getViolations()->count()) {
    return new JsonResponse($result->getViolations());
}

$data = $result->getData();
```

That's it! We have now normalized data that we can process further.

Introduction
------------

[](#introduction)

This library supports numerous scalar data type definitions and two complex type definitions: arrays ("collections") and hash ("json") out the box. Data type definition called `Element` in this library. You can add your own data types by extending `AbstractElement` class.

To use specific element you should first instantiate it by just calling:

```
use CodexSoft\Transmission\Schema\Elements\BoolElement;

$element = new BoolElement();
```

or by using `Accept` fascade:

```
use CodexSoft\Transmission\Schema\Accept;

$boolean = Accept::bool();
```

Every element has some basic attributes:

- is it nullable or not
- is it required or not
- what is default value for optional elements
- should be value type strictly match element data type or can be automatically converted
- is it deprecated\* or not
- label\* (or, comment)

More specific elements have more specific attributes. For example: minimal length for strings, max value for integer, can be string blank, etc.

When strict type check enabled for integer, '42' will generate violation for this element.

List of all built-in elements:

ElementValue exampleBoolElementtrue, falseCollectionElement\[1, 2, 3\]DateElement'2020-05-25'DateTimeElement'2020-05-10 12:34:56'EmailElement''FloatElement42.4IntegerElement42JsonElement\['hello' =&gt; 'world'\]NumberElement42.4, 55ScalarElement'hello', 42, trueStringElement'hello world'TimeElement'12:34:56'TimestampElement1541508448UrlElementUuidElement'a8d8f871-481f-436f-b22f-6598f89635ca'Usage
-----

[](#usage)

Basic normalizing for boolean data.

```
use CodexSoft\Transmission\Schema\Accept;

$userInput = 'test';

$boolean = Accept::bool();
$result = $boolean->validateNormalizedData($userInput);
$result->getViolations()->count(); // 0
$result->getData(); // true

$strictBoolean = Accept::bool()->strict();
$result = $boolean->validateNormalizedData($userInput);
$result->getViolations()->count(); // 1
$result->getData(); // 'test'
```

- `label` and `deprecated` attributes exists for historical reasons, because this library started as unified schema description for further OpenApi schema generation (check [codexsoft/transmission-openapi3](https://github.com/codexsoft/transmission-openapi3)).

Always check violations count before using normalized data, as in that case original input data will be stored in `result.data`.

No exceptions are trown automatically but you can write a wrapper to force throwing exceptions in case of violations detected or handle this case in another way.

Testing
-------

[](#testing)

```
php ./vendor/bin/phpunit
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~35 days

Recently: every ~93 days

Total

16

Last Release

1511d ago

Major Versions

v0.0.3 → v1.0.02020-10-13

v1.0.8 → v2.0.02021-04-23

PHP version history (3 changes)v0.0.1PHP ^7.4.0

v1.0.7PHP ^7.4|^8

v2.0.0PHP ^8

### Community

Maintainers

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

---

Top Contributors

[![kozubsky](https://avatars.githubusercontent.com/u/29902572?v=4)](https://github.com/kozubsky "kozubsky (104 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codexsoft-transmission-schema/health.svg)

```
[![Health](https://phpackages.com/badges/codexsoft-transmission-schema/health.svg)](https://phpackages.com/packages/codexsoft-transmission-schema)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M234](/packages/api-platform-core)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[horstoeko/zugferd

A library for creating and reading european electronic invoices

4044.3M17](/packages/horstoeko-zugferd)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M340](/packages/drupal-core-recommended)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M385](/packages/shopware-core)

PHPackages © 2026

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