承接 specdocular/php-json-schema 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

specdocular/php-json-schema

最新稳定版本:v0.1.0

Composer 安装命令:

composer require specdocular/php-json-schema

包简介

PHP implementation of JSON Schema (Draft 2020-12)

README 文档

README

Latest Version on Packagist PHP Version Tests codecov Code Style

A type-safe, fluent PHP implementation of JSON Schema Draft 2020-12.

Installation

composer require specdocular/php-json-schema

Usage

Build JSON Schema definitions using a fluent, type-safe API:

use Specdocular\JsonSchema\Draft202012\StrictFluentDescriptor;
use Specdocular\JsonSchema\Draft202012\Keywords\Properties\Property;

$schema = StrictFluentDescriptor::object()
    ->properties(
        Property::create('name', StrictFluentDescriptor::string()->minLength(1)),
        Property::create('email', StrictFluentDescriptor::string()->format('email')),
        Property::create('age', StrictFluentDescriptor::integer()->minimum(0)),
    )
    ->required('name', 'email');

// Compile to array
$compiled = $schema->compile();

// Or encode directly to JSON
$json = json_encode($schema, JSON_PRETTY_PRINT);

Strict vs Loose Descriptors

  • StrictFluentDescriptor (recommended) — provides type-specific method autocomplete. Methods like minLength() are only available on string schemas, minimum() only on numeric schemas, etc.
  • LooseFluentDescriptor — exposes all keywords on every schema. Useful when building schemas with multiple types.

Features

  • Full JSON Schema Draft 2020-12 support (all 50 keywords, 7 vocabularies)
  • Type-safe fluent API with IDE autocomplete
  • Extensible keyword and vocabulary system
  • Built-in schema validation (VocabularyValidator, MetaSchemaValidator)
  • Framework-agnostic — no dependencies on Laravel or any framework

Note: This library builds JSON Schema definitions. It does not validate data against schemas — use a validation library like justinrainbow/json-schema for that.

Related Packages

Package Description
specdocular/php-openapi Object-oriented OpenAPI 3.1.x builder (uses this package)
specdocular/laravel-rules-to-schema Convert Laravel validation rules to JSON Schema (uses this package)
specdocular/laravel-openapi Laravel integration for OpenAPI generation

License

MIT. See LICENSE for details.

统计信息

  • 总下载量: 595
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固