PHPackages                             onlinesid/json-schema-provider - 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. onlinesid/json-schema-provider

ActiveLibrary[API Development](/categories/api)

onlinesid/json-schema-provider
==============================

Json Schema Silex Service Provider

v0.2(7y ago)248.1k↓50%1MITPHPPHP &gt;=5.6.0

Since Mar 9Pushed 7y ago2 watchersCompare

[ Source](https://github.com/onlinesid/json-schema-provider)[ Packagist](https://packagist.org/packages/onlinesid/json-schema-provider)[ RSS](/packages/onlinesid-json-schema-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

json-schema-provider
====================

[](#json-schema-provider)

Json Schema `Silex Service Provider` and validator tool

A Silex Service Provider for validating `JSON` data against a given `Schema`.

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

[](#installation)

### Library

[](#library)

```
$ git clone https://github.com/onlinesid/json-schema-provider.git

```

### Dependencies

[](#dependencies)

#### [`Composer`](https://github.com/composer/composer) (*will use the Composer ClassLoader*)

[](#composer-will-use-the-composer-classloader)

```
$ wget http://getcomposer.org/composer.phar
$ php composer.phar require onlinesid/json-schema-provider:dev-master

```

Usage
-----

[](#usage)

#### Registering the Service Provider

[](#registering-the-service-provider)

```
$app->register(new OnlineSid\Silex\Provider\JsonSchema\ServiceProvider(), array(
    'json-schema.options' => array(
        'json_schema_dir' => __DIR__.'/public/json-schema/',
        'json_message_dir' => __DIR__.'/public/json-message/',
        'default_json_message' => 'default.json',
    ),
));
```

- `json_schema_dir`: where the json schema files are located
- `json_message_dir`: where the json files for custom error messages are located
- `default_json_message`: json file where default error messages are located, file must be in directory `json_message_dir`

#### Usage in controller

[](#usage-in-controller)

```
$validator = $this->app['json-schema-validator'];
$validation_result = $validator->validate(array(
    'request' => $this->request->get('booking'), // array to validate
    'json_schema' => 'booking.json', // under json_schema_dir
    'json_message' => 'booking.json', // under json_message_dir
));

// check $validation_result->isValid() to see if validation pass or fail
```

\####json-schema/booking.json See [json-schema](http://json-schema.org/) for more details.

This is your json schema containing constraints/rules

```
{
  "type": "object",
  "properties": {
    "first_name": {
      "type": "string",
      "required": true,
      "maxLength": 100
    },
    "last_name": {
      "type": "string",
      "required": true,
      "maxLength": 100
    }
  }
}
```

\####json-message/booking.json You can specify your own custom error messages.

```
{
  "first_name": {
    "label": "First name",
    "messages": {
      "required": "{{ label }} is required.",
      "maxLength": "{{ label }} must not be more than {{ schema.maxLength }} characters long."
    }
  },
  "last_name": {
    "label": "Last name",
    "messages": {
      "required": "{{ label }} is required.",
      "maxLength": "{{ label }} must not be more than {{ schema.maxLength }} characters long."
    }
  }
}
```

\####json-message/default.json You can specify global default error messages (e.g.: not per field but per constraint rule type)

```
{
  "messages": {
    "required": "Required field.",
    "minLength": "Must be {{ schema.minLength }} chars or more.",
    "maxLength": "Must not be more than {{ schema.maxLength }} chars.",
    "pattern": "Incorrect format"
  }
}
```

Running the tests
-----------------

[](#running-the-tests)

```
$ phpunit

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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 ~1105 days

Total

2

Last Release

2617d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4.0

v0.2PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8938cbf4c5b34440ebf00efd7786f01134da5e6820fe1631bd11020bb2e5df5b?d=identicon)[onlinesid](/maintainers/onlinesid)

---

Top Contributors

[![onlinesid](https://avatars.githubusercontent.com/u/99542?v=4)](https://github.com/onlinesid "onlinesid (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/onlinesid-json-schema-provider/health.svg)

```
[![Health](https://phpackages.com/badges/onlinesid-json-schema-provider/health.svg)](https://phpackages.com/packages/onlinesid-json-schema-provider)
```

###  Alternatives

[cebe/php-openapi

Read and write OpenAPI yaml/json files and make the content accessable in PHP objects.

49815.4M86](/packages/cebe-php-openapi)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2292.2M24](/packages/php-opencloud-openstack)[devizzent/cebe-php-openapi

Read and write OpenAPI yaml/json files and make the content accessable in PHP objects.

379.0M49](/packages/devizzent-cebe-php-openapi)[nfephp-org/sped-cte

API para geração e comunicação da CTe com as SEFAZ autorizadoras.

113227.7k1](/packages/nfephp-org-sped-cte)[tomaj/nette-api

Nette api

36261.8k4](/packages/tomaj-nette-api)[nfephp-org/sped-mdfe

API para geração e comunicação da MDFe com as SEFAZ autorizadoras.

50135.1k](/packages/nfephp-org-sped-mdfe)

PHPackages © 2026

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