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. [API Development](/categories/api)
4. /
5. codexsoft/transmission-schema

ActiveLibrary[API Development](/categories/api)

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↓90%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 3w 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

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

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

1556d 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://avatars.githubusercontent.com/u/29902572?v=4)[Dmitriy Kozubskiy](/maintainers/kozubsky)[@kozubsky](https://github.com/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

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[api-platform/core

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

2.6k50.1M314](/packages/api-platform-core)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51090.8k2](/packages/web-auth-webauthn-framework)[api-platform/validator

API Platform validator component

264.1M23](/packages/api-platform-validator)

PHPackages © 2026

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