PHPackages                             yuloh/illuminate-json-guard - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. yuloh/illuminate-json-guard

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

yuloh/illuminate-json-guard
===========================

Laravel/Lumen integration for league/json-guard

14.8kPHP

Since Dec 23Pushed 9y agoCompare

[ Source](https://github.com/matt-allan/illuminate-json-guard)[ Packagist](https://packagist.org/packages/yuloh/illuminate-json-guard)[ RSS](/packages/yuloh-illuminate-json-guard/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Json Schema Validation For Laravel And Lumen
============================================

[](#json-schema-validation-for-laravel-and-lumen)

Laravel/Lumen integration for league/json-guard.

This package is experimental and could break at any time.

Install
-------

[](#install)

Via Composer

```
$ composer require yuloh/illuminate-json-guard
```

### Register The Service Provider

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

Add the following line to `app/boostrap.php`:

```
$app->register(Yuloh\JsonGuard\Illuminate\LumenServiceProvider::class);
```

### Publish The Config File

[](#publish-the-config-file)

As Lumen does not ship with a publish command, you will have to copy the config file manually.

```
cp ./vendor/league/illuminate-json-guard/config/json-guard.php ./config/json-guard.php
```

Usage
-----

[](#usage)

### Controller Validation

[](#controller-validation)

You can use the provided `ValidatesJsonRequests` trait to easily validate requests against a JSON Schema.

The trait provides a `validateJson` method. Simply call the method with the current request and the name of the schema you would like to use, and the request body will be validated against the schema.

if validation fails, the method will throw a `JsonSchemaValidationException`. The exception will be converted into a JSON response will all of the relevant error messages.

```
use Yuloh\JsonGuard\Illuminate\Http\ValidatesJsonRequests;

class UsersController extends Controller
{
    use ValidatesJsonRequests;

    public function show(Request $request, int $id)
    {
        $this->validateJson($request, 'user.json');

        return User::find($id);
    }
}
```

### Route Middleware

[](#route-middleware)

A route middleware is also included. The route middleware takes the name of the schema you would like to use the as the only parameter. If validation fails the middleware will return a JSON response of the errors instead of passing through to your handler.

```
$app->post('/users', ['middleware' => 'json-schema:user.json', function () {
    //
}]);
```

### Loading Schemas

[](#loading-schemas)

@todo

### Localization

[](#localization)

@todo

### Customizing The Error Response

[](#customizing-the-error-response)

@todo

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9440455?v=4)[Matt A](/maintainers/matt-allan)[@matt-allan](https://github.com/matt-allan)

### Embed Badge

![Health badge](/badges/yuloh-illuminate-json-guard/health.svg)

```
[![Health](https://phpackages.com/badges/yuloh-illuminate-json-guard/health.svg)](https://phpackages.com/packages/yuloh-illuminate-json-guard)
```

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

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