PHPackages                             gilsegura/psr-validator - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. gilsegura/psr-validator

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

gilsegura/psr-validator
=======================

This is a project providing infrastructure for validating PSR HTTP messages.

1.0.2(2w ago)06102MITPHPPHP ^8.4CI passing

Since Dec 3Pushed 2w ago1 watchersCompare

[ Source](https://github.com/gilsegura/psr-validator)[ Packagist](https://packagist.org/packages/gilsegura/psr-validator)[ RSS](/packages/gilsegura-psr-validator/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (9)Versions (5)Used By (2)

PSR VALIDATOR
=============

[](#psr-validator)

[![tests](https://github.com/gilsegura/psr-validator/actions/workflows/tests.yaml/badge.svg)](https://github.com/gilsegura/psr-validator/actions/workflows/tests.yaml)[![codecov](https://camo.githubusercontent.com/fe0902e606ee1ae19f445834b311b4584382aeb6a74e8e9abb1f362d59beefbb/68747470733a2f2f636f6465636f762e696f2f6769746875622f67696c7365677572612f7073722d76616c696461746f722f67726170682f62616467652e737667)](https://codecov.io/github/gilsegura/psr-validator)[![static analysis](https://github.com/gilsegura/psr-validator/actions/workflows/static-analysis.yaml/badge.svg)](https://github.com/gilsegura/psr-validator/actions/workflows/static-analysis.yaml)[![coding standards](https://github.com/gilsegura/psr-validator/actions/workflows/coding-standards.yaml/badge.svg)](https://github.com/gilsegura/psr-validator/actions/workflows/coding-standards.yaml)

Framework-agnostic validation of PSR-7 messages against JSON Schema. It validates requests, responses and server requests, composes validators into a chain, and loads schemas from files or raw strings. The `gilsegura/psr-messages-bundle`package uses it as the validation middleware in a controller pipeline.

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

[](#installation)

```
composer require gilsegura/psr-validator
```

Message validators
------------------

[](#message-validators)

Each validator is an invokable that takes a PSR-7 message, validates it and returns it (or throws a `ValidationExceptionInterface` on failure):

- **`RequestValidator`** — validates an outgoing `RequestInterface`.
- **`ResponseValidator`** — validates a `ResponseInterface`.
- **`ServerRequestValidator`** — validates an incoming `ServerRequestInterface`.
- **`ValidatorChain`** — a `MessageValidatorInterface` that runs several validators in sequence, so request and response checks compose into one.

`MessageValidatorInterface` is the common contract (`__invoke(MessageInterface): MessageInterface`).

Schema validation
-----------------

[](#schema-validation)

- **`SchemaValidatorInterface` / `Schema\SchemaValidator`** — validate decoded data against a schema object, returning the list of violations; `ValidatorException`surfaces a schema-level failure.
- **`Exception\ValidationExceptionInterface`** — the marker validation failures implement, so callers catch a single type regardless of which part failed.

Schema factories
----------------

[](#schema-factories)

A schema factory builds the schema object the validators check against:

- **`SchemaFactoryInterface`** — the contract; an invokable returning the schema.
- **`SchemaFactory\FileFactory`** — loads a JSON Schema from a `.json` file.
- **`SchemaFactory\RawFactory`** — builds a schema from a raw string.
- **`SchemaFactory\SchemaFactoryException`** — raised when a schema cannot be built.

Middleware (PSR-15)
-------------------

[](#middleware-psr-15)

**`Middleware\ValidationMiddleware`** validates a message as part of a PSR-15 pipeline, so validation runs inline with the request flow rather than being called by hand.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

48

↑

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

4

Last Release

20d ago

Major Versions

0.1.0 → 1.0.02026-06-11

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

1.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29969702?v=4)[josué](/maintainers/gilsegura)[@gilsegura](https://github.com/gilsegura)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gilsegura-psr-validator/health.svg)

```
[![Health](https://phpackages.com/badges/gilsegura-psr-validator/health.svg)](https://phpackages.com/packages/gilsegura-psr-validator)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.5k1.5M88](/packages/mcp-sdk)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[cakephp/authentication

Authentication plugin for CakePHP

1214.1M106](/packages/cakephp-authentication)

PHPackages © 2026

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