PHPackages                             jdesrosiers/silex-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. jdesrosiers/silex-json-schema-provider

AbandonedLibrary[Parsing &amp; Serialization](/categories/parsing)

jdesrosiers/silex-json-schema-provider
======================================

A Silex service provider for working with JSON Schema

v1.0.1(8y ago)63.6kMITPHPCI failing

Since Mar 29Pushed 6y ago1 watchersCompare

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

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

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

[](#silex-json-schema-provider)

[![Build Status](https://camo.githubusercontent.com/c8e86733632aabb158df6290ae72a30555936992425ffb8055c65d63df982a36/68747470733a2f2f7472617669732d63692e6f72672f6a646573726f73696572732f73696c65782d6a736f6e2d736368656d612d70726f76696465722e737667)](https://travis-ci.org/jdesrosiers/silex-json-schema-provider)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b3040d6da28b9d5336a7378bc86f231c8f2fd1c112254c4e27af64142644e7e8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a646573726f73696572732f73696c65782d6a736f6e2d736368656d612d70726f76696465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdesrosiers/silex-json-schema-provider/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/117972d683ccf86337c4c135a2b4b48105aeee4f8b79108e2021d0c6628cf36b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a646573726f73696572732f73696c65782d6a736f6e2d736368656d612d70726f76696465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jdesrosiers/silex-json-schema-provider/?branch=master)

silex-json-schema-provider is a Silex service provider for working with JSON Schema.

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

[](#installation)

Install the silex-json-schema-provider using [composer](http://getcomposer.org/). This project uses [sematic versioning](http://semver.org/).

```
composer require jdesrosiers/silex-json-schema-provider "~1.0"
```

Parameters
----------

[](#parameters)

- **json-schema.correlationMechanism**: ("profile" or "link") Defaults to "link".
- **json-schema.describedBy**: (string) A URI identifying the location of a schema that describes the response.

Services
--------

[](#services)

- **json-schema.schema-store**: An instance of SchemaStore as described here .
- **json-schema.validator**: An object that exposes the Jsv4 methods described here .

Registering
-----------

[](#registering)

```
$app->register(new JDesrosiers\Silex\Provider\JsonSchemaServiceProvider());
```

JSON Validation
---------------

[](#json-validation)

JSON Schema validation is supported by .

```
$schemaJson = add("/schema/foo", json_decode($schemaJson));
$schema = $app["json-schema.schema-store"]->get("/schema/foo");
$validation = $app["json-schema.validator"]->validate($data, $schema);
```

Correlation
-----------

[](#correlation)

The JSON Schema specification has two recommendations for correlating a schema to a resource. This service provider registers after middleware that supports both. See  for more information on schema correlation. Set the `$app["json-schema.describedBy"]` parameter to the schema that the response should be correlated to.

```
$app->get("/foo/{id}", function ($id) use ($app) {
    $app["json-schema.describedBy"] = "/schema/foo";
    return JsonResponse::create(array("id" => $id));
});
```

Full Example
------------

[](#full-example)

```
$app["json-schema.schema-store"]->add("/schema/foo", $app["schemaRepository"]->fetch("foo"));

$app->put("/foo/{id}", function (Request $request, $id) use ($app) {
    $data = json_decode($request->getContent());

    $schema = $app["json-schema.schema-store"]->get("/schema/foo");
    $validation = $app["json-schema.validator"]->validate($data, $schema);
    if (!$validation->valid) {
        $error = array("validationErrors" => $validation->errors);
        return JsonResponse::create($error, Response::HTTP_BAD_REQUEST);
    }

    $isCreated = !$app["fooRepository"]->contains($id);
    $app["fooRepository"]->save($id, $data);

    $app["json-schema.describedBy"] = "/schema/foo";
    return JsonResponse::create($data, $isCreated ? Response::HTTP_CREATED : Response::HTTP_OK);
});
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

2947d ago

Major Versions

v0.x-dev → v1.0.02016-06-06

### Community

Maintainers

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

---

Top Contributors

[![jdesrosiers](https://avatars.githubusercontent.com/u/716571?v=4)](https://github.com/jdesrosiers "jdesrosiers (7 commits)")

---

Tags

jsonjson-schemasilexJSON Hyper-Schemahyper-schemajsv4

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

69124.2k1](/packages/m1-vars)[jdesrosiers/silex-jms-serializer-provider

A silex service provider that integrates jms/serializer into silex

11126.3k2](/packages/jdesrosiers-silex-jms-serializer-provider)[jms/serializer-service-provider

Silex Service Provider for the Serializer Bundle

117.9k2](/packages/jms-serializer-service-provider)

PHPackages © 2026

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